Specifications
Section 4. CRBasic - Native Language Programming
4-8
Strings can be dimensioned only up to 2 dimensions instead of the 3 allowed
for other data types. (This is because the least significant dimension is actually
used as the size of the string.)
Public FirstName AS STRING ‘Creates string of 16 characters
Public LastName AS STRING * 20 ‘Creates string of 20 characters
4.4.5 Numerical Expressions with Floats, Longs and Booleans
Floats, Longs and Booleans are converted automatically into each other
Boolean from Float or Long
When a float or long integer is converted to a boolean, zero is False (0), Any
non-zero value will set the Boolean to True (-1)
Public X, Y
Public I AS Long, B AS Boolean
BeginProg
X = 0
Y = 0.125
I = 126
B = X ‘This will set B = False (0)
B = Y ‘This will Set B = True (-1)
B = I ‘This will Set B = True (-1)
EndProg
Float from Long or Boolean
When a Long or Boolean is converted to a float, the integer value is loaded
into the Float. Booleans will be converted as –1 or 0 depending on whether
the value is true or false. Note that integers greater than 24 bits (16,777,215;
the size of the mantissa for a Float) will lose resolution when converted to a
float.
Long from Float or Boolean
Booleans will be converted as –1 or 0 depending on if the value is true or false.
When a Float is converted to a Long integer it is truncated. This conversion is
the same as the INT function (Section 8). Note that the integer conversion is to
the integer equal to or less than the value of the float. This may not be
intuitive for negative numbers, for example:
Dim I as Float
BeginProg
I = 4.6 ‘This will set I to 4.
I = -4.6 ‘This will set I to –5.
EndProg
If the Float is greater than maximum long integer, the integer will be set to the
maximum (+2,147,483,647). If the float is less than the minimum long integer,
the integer is set to the minimum (–2,147,483,648).