VAL function
Purpose:
VAL converts a string to a double number.
Syntax:
RetDub = VAL(StringNum AS STRING)
Return Value:
- Data type: STRING
RetDub DOUBLE floating
point number converted from StringNum. If
StringNum is not a valid number, zero will
be returned.
Parameters:
- Data type: STRING
StringNum string literal or variable
containing digits.
|
Remarks:
- C-Style and BASIC-Style hexadecimal syntax are supported.
- Whitespace between digits is removed. VAL("1 2 3 . 4
5") returns 123.45
- Parsing will break on an unknown character. VAL("12ABC") returns 12.
- Scientific "E" notation has double-precision support.
Example:
PRINT VAL("0x11111111") ' C Code hexadecimal literal string argument
PRINT VAL("&H11111111") ' BASIC hexadecimal literal string argument
PRINT VAL("&O11111111") ' Octal literal string argument
PRINT VAL("&B11111111") ' Binary literal string argument
Result:
286331153
286331153
2396745
255
BCX Console Sample Programs using the VAL function.
VALL function
Purpose:
VALL converts a string to an LDOUBLE
number.
Syntax:
RetLDub = VALL(StringNum AS STRING)
Return Value:
- Data type: STRING
RetLDub LDOUBLE
floating point number converted from StringNum. If StringNum is not a
valid number, zero will be returned.
Parameters:
- Data type: STRING
StringNum string literal or variable
containing digits.
|
Example:
DIM StringNum$
DIM RetDub#
DIM RetLDub AS LDOUBLE
StringNum$ = "3.141592653589793239"
RetDub# = VAL(StringNum$)
PRINT RetDub#
RetLDub = VALL(StringNum$)
PRINT RetLDub
Result:
3.14159265358979
3.141592653589793239