Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Type Conversion
◄Data Types► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Type Conversion
When necessary, BASIC converts a numeric constant from one type to another,
according to these rules:
──────────────────────────────────────────────────────────────────────────────
Condition Result
──────────────────────────────────────────────────────────────────────────────
If a numeric constant is assigned The numeric constant is stored
to a numeric variable of a different as the type declared in the
type variable name
If a string variable is assigned to The "Type mismatch" error
a numeric value or vice versa message is generated
If a floating-point value is converted The fractional portion is
to an integer rounded
──────────────────────────────────────────────────────────────────────────────
Currency values are treated as floating-point numbers.
──────────────────────────────────────────────────────────────────────────────
Type Conversion in Expression Evaluation
During expression evaluation, the operands in an arithmetic or relational
operation are converted to the same degree of precision, that of the most
precise operand, as each operation is performed. Also, the result of an
arithmetic operation is returned to the final degree of precision.
Type Conversion in Logical Expressions
Logical operators such as AND and NOT convert their operands to
long integers if necessary. Operands must be in the range -2,147,483,648
to 2,147,483,647 or an "Overflow" error message is generated.
See Also ◄BASIC Literal Constants►