lang • type • float

Float

DIM Var AS Float

This native datatype represents a double floating point value, i.e. an eight byte floating point value.

The value of Float is a number between -8.98846567431105E+307 and +8.98846567431105E+307

The precision of Float is 52 binary digits, which is 16 decimal digits (2^-52). This means: if you add a (positive) number which is less than 2E-16 to 1.0, then the result will be exactly 1.0.

Examples

Dim x As Float = Sin(0.32)
Dim y As Float = x - (0.32 - 0.32 ^ 3 / (2 * 3))

Print x;; y
0.314566560616	2.789394945107E-5

Overflow during Float arithmetic operations is not detected! Instead, the result is set to 1E+2147483647 or -1E+2147483647 depending on the direction of the overlow.

If such an overflowed number is used in further expressions, then the execution stops and a message window shows "Mathematic error". The value of a Float can be compared against maxfloat or minfloat.

Examples

Const maxfloat As Float = +8.98846567431105E+307
Const minfloat As Float = -8.98846567431105E+307
...
If y > maxfloat Or y < minfloat Then
  Print "Float y overflow"
Else
  x = y / 23000
Endif

See also