Type Casting
Explicit type convertion of a value expression into a specific Data Type. This is often makes sense when a Function requires a specific data type. Some output functions adapt the display format ti the data type passed.
For example the calculation of a bit manipulation will result in the next larger data type if the original data type possibly may not have enough space to accomodate the result (Data types smaller than Long).
Example 1:
dim a,b as byte print hex(a+b) ' The result will be a Word, ' the Hex-Output function will therefor display a Word value
You could force a type conversion to define the resulting data type.
Type Conversion Functions
- byte( Expression )
- int8( Expression )
- uint8( Expression )
- integer( Expression )
- word( Expression )
- int16( Expression )
- uint16( Expression )
- int24( Expression )
- uint24( Expression )
- long( Expression )
- longint( Expression )
- int32( Expression )
- uint32( Expression )
- single( Expression )
See also:
Example 2:
dim a,b as byte print hex(byte(a+b)) ' The result will be of type Byte, ' the Hex-Output function will therefor display a Byte value