VAL edit

Syntax edit

numericValue = VAL(string$)

Description edit

If string$ contains the characters of a number in any of the standard FB formats (decimal, hex, octal or binary), VAL returns the number's value.

VAL ignores leading spaces in string$. When it finds a non-space character, it evaluates the remaining characters in string$ until it encounters a character which is not part of the number. Thus, for example, the string "3245.6" would be evaluated as 3245.6, but the string "32W45.6" would be evaluated as 32. If the first non-space character in string$ can't be recognized as part of a number, VAL returns zero. VAL performs the opposite of functions such as STR$, HEX$, OCT$, BIN$ and UNS$.

Example edit

DATA "-3.2", "1.4E2", "&4C1", "9+7"
FOR i = 1 TO 4
   READ s$
   PRINT s$, VAL(s$)

program output:
<code>-3.2 -3.2
&4C1 1271
9+7 9

Notes edit

If string$ represents an integer, consider using the VAL& function, which is faster.

See Also edit

VAL&amp; MKI$; CVI; STR$; HEX$; BIN$; OCT$; UNS$; <Image was here> Appendix C: Data Types and Data Representation