UNSIGNED

From QB64 Wiki
Revision as of 19:23, 15 October 2009 by imported>Clippy
Jump to navigation Jump to search

_UNSIGNED defines a numerical value as being positive only in QB64 only.


Syntax: _DEFINE LetterRange AS [_UNSIGNED] datatype


  • Although _UNSIGNED values can use negative values the result subtracts from the highest value of the number's type keeping it positive.
  • Datatype can be any of the following: INTEGER, SINGLE, DOUBLE, LONG, STRING, _BIT, _BYTE, _INTEGER64, _FLOAT
  • _UNSIGNED can be used in a _DEFINE statement to set undefined variable name first letters as all positive only values.
  • Can also be used in DIM statements or Subprocedure parameter definitions following AS.
  • _UNSIGNED allows larger positive numerical variable value limits than signed ones.
  • The Unsigned variable type suffix used is the tilde ~ before the number's own type suffix: variablename~&


Example 1: DIM intvariable AS _UNSIGNED INTEGER


Example 2: How negative values affect the _UNSIGNED value returned by a byte(8 bits).

00000001 - unsigned & signed are both 1
01111111 - unsigned & signed are both 127
11111111 - unsigned is 255 but signed is -1
11111110 - unsigned is 254 but signed is -2
11111101 - unsigned is 253 but signed is -3



See also: DECLARE, SUB, FUNCTION, DIM, _DEFINE, DEFSTR, DEFLNG, DEFINT, DEFSNG, DEFDBL, ABS, SGN


Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage