Floating Point Numbers
A floating-point number is a number consisting of an optional sign, one or more digits, a decimal point optionally followed by one or more digits, optionally followed by the letter
e or
E, optionally followed by a sign, followed by one or more digits.
A number without a decimal point is an
Integer numbers.
[ sign ] digit [ digit [ ... ] ] . [ { digit [ digit [ ... ] ] } ] [ { e | E } [ sign ] digit [ digit [ digit [ ... ] ] ]
-
sign : + or -, if the sign is missing, it is presumed to be +.
-
digit : 0 through 9.
-
. : indicates the number is a floating point number rather than an Integer numbers.
-
e or E : indicates the number has an exponent. The case is ignored. There must be at least one digit after the E or e, optionally preceded by a sign.
At least one digit must appear before the decimal point. Note that while no digits are required after the decimal point, at least one digit
must follow an
E or
e if it is used.
If there is no decimal point and no exponant, then the number will be interpreted as an
integer.
The following are all valid floating-point numbers:
0.0 +0.0 0. -0.0 0.0e+1 0.0e-1 0.e+0 0.0e0 0.0e-0 -0.0e-0 (all are the same 0.0) 0.7 -0.3 1.0 -1. 1. -1.0 37.16 -40.33 +1.5 -12.34 3.14159267 1.39e5 1.7E-3
The following are all the same:
1000000.0 1.E+7 1e7 1.0e7 10.0e6 0.100E8 10000000.0E-1
Gambas provides two different floating-point types:
|
Floating-Point
|
Description
|
Default value
|
Size in memory
|
Single
|
-1.7014118E-38 .. +1.7014118E+38
|
0.0
|
4 bytes
|
Float
|
-8.98846567431105E-307 .. +8.98846567431105E+307
|
0.0
|
8 bytes
|
See also