Q(uick)BASIC Function: CDBL
Quick View
CDBL
A conversion function that converts a numeric expression to a double-precision number
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- CDBL (numeric-expression)
Description/Parameter(s)
The numeric-expression may be any numeric expression. This function has the same effect as assigning the numeric expression to a double-precision variable.
Note that the results of CDBL are no more accurate than the original expression. The added digits of precision are not significant unless the expression is calculated with double-precision accuracy.
Example
The following example demonstrates how the precision of the numeric expression affects the result of using CDBL:
X = 7/9
X# = 7/9
PRINT X
'Both X# and CDBL(X) will be accurate to only 7 decimal
'places, because 7/9 is evaluated in single precision.
PRINT X#
PRINT CDBL(X)
'Accurate to 15 decimal places.
PRINT 7#/9#
Sample Output:
.7777778 .7777777910232544 .7777777910232544 .7777777777777778Syntax
- CDBL (numeric-expression)
Description/Parameter(s)
numeric-expression | Any numeric expression. |
Returns | A double-precision value. |
Usage Notes
- This function has the same effect as assigning the numeric expression to a double-precision variable.
- Note that the results of CDBL are no more accurate than the original expression. The added digits of precision are not significant unless the expression is calculated with double-precision accuracy.
Example
This example demonstrates how using the CDBL function affects precision.
X = 7 / 9
X# = 7 / 9
PRINT X
'Both X# and CDBL(X) will be accurate to only 7 decimal
'places, because 7/9 is evaluated in single precision.
PRINT X#
PRINT CDBL(X)
'Accurate to 15 decimal places.
PRINT 7# / 9#
Sample Output:
.7777778 .7777777910232544 .7777777910232544 .7777777777777778