Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Arithmetical Functions
Arithmetic Operators
Array Declaration
Assignment Operators
Binary Data Representation
Bits Manipulation Functions
Character Test Functions
Comparison methods
Complex numbers
Constant Declaration
Constant Expression
Conversion Functions
Datatype Functions
Date & Time Functions
Enumeration declaration
Error Management
Event Loop
Event Management
Events declaration
External Function Management
File & Directory Functions
File & Directory Paths
File mode syntax
Floating Point Numbers
Formatting functions
Gambas Object Model
Global Special Event Handlers
Integer numbers
Intrinsic Functions
Language Constants
Localization and Translation Functions
Local Variable Declaration
Logarithms & Exponentials Functions
Logical Operators
Loop Control Structures
Method Declaration
Miscellaneous Control Structures
Miscellaneous Functions
Native Arrays
Native Container Classes
Object & Class Management
Operator Evaluation Order
Predefined Constants
Process Management
Property Declaration
Random Numbers Functions
Special Methods
Stream & Input/Output functions
String Functions
String Operators
Structure declaration
Test Control Structures & Functions
Trigonometric Functions
User-defined formats
Using reserved keywords as identifiers
Variable Declaration
Last Changes
Search the wiki
To Do
Wiki License
Wiki Manual

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