Talk:Documentation/BASIC Guide/Numbers

From Apache OpenOffice Wiki
Jump to: navigation, search

Special numeric values

Is it possible to assign a special numeric value to a variable? The following code errors out:

DIM F#
F# = VAL# ("NaN")

--Yecril71pl 10:56, 6 March 2012 (UTC)

What "special numeric value" did you have in mind?
I presume the above code errors out because of the "#" after the "VAL". It is neither necessary nor possible to specify the precision of the functions; Basic will provide the precision indicated by the destination (double, in this case).
Please note that VAL only converts numeric characters ("123"), and would yield zero for the above case. The ASC function will return the numeric value of a character, but only of one character at a time.
VAL("12") = 12 (decimal)
ASC("12") = 49 (&H31 for character "1"; the "2" is ignored)
The on-line Help is your friend for things like this; it is very complete, where this manual is an introduction. --TJ (Talk | Contribs) 00:15, 7 March 2012 (UTC)
Personal tools