The Float type represents a double-precision 64-bit floating-point number (IEEE 754).
Floats are defined using a decimal point. Scientific notation is also supported using the e or E suffix. You can use type inference or explicit typing.
// Type inference
var f1 := 1.234;
var f2 := 1.0;
var f3 := 1e-3; // 0.001
// Explicit typing
var pi : Float := 3.14159;
var avogadro : Float := 6.022e23; Standard arithmetic operators apply: +, -, *, and / (floating-point division).
var x := 10 / 3; // 3.33333333333333 To control the precision when converting to a string, use the FloatToStr function or .ToString with parameters.
var f := 1.234567;
PrintLn(f.ToString); // "1.234567"
PrintLn(FloatToStr(f, 2)); // "1.23" 1.234567 1.23
The Float type supports IEEE 754 special values for representing infinity and invalid operations.
INF: Positive Infinity (e.g., 1.0 / 0.0)NegINF: Negative Infinity (e.g., -1.0 / 0.0)NaN: Not a Number (e.g., 0.0 / 0.0 or Sqrt(-1))You can check for these values using the helper functions:
IsNaN(val)IsInfinite(val)var x := 1.0 / 0.0;
if IsInfinite(x) then
PrintLn('Infinity reachable'); Infinity reachable
Round, Trunc, Ceil, Floor).