Float built-in type.


The float built-in type is a 64-bit double-precision floating-point number, equivalent to double in C++. This type has 14 reliable decimal digits of precision. The float type can be stored in Variant, which is the generic type used by the engine. The maximum value of float is approximately 1.79769e308, and the minimum is approximately -1.79769e308.

Most methods and properties in the engine use 32-bit single-precision floating-point numbers instead, equivalent to float in C++, which have 6 reliable decimal digits of precision. For data structures such as Vector2 and Vector3, Godot uses 32-bit floating-point numbers.

Math done using the float type is not guaranteed to be exact or deterministic, and will often result in small errors. You should usually use the @GDScript.is_equal_approx and @GDScript.is_zero_approx methods instead of == to compare float values for equality.




float ( bool from )


float ( int from )


float ( String from )

Method Descriptions

float float ( bool from )

Cast a bool value to a floating-point value, float(true) will be equal to 1.0 and float(false) will be equal to 0.0.

float float ( int from )

Cast an int value to a floating-point value, float(1) will be equal to 1.0.

float float ( String from )

Cast a String value to a floating-point value. This method accepts float value strings like "1.23" and exponential notation strings for its parameter so calling float("1e3") will return 1000.0 and calling float("1e-3") will return 0.001. Calling this method with an invalid float string will return 0. This method stops parsing at the first invalid character and will return the parsed result so far, so calling float("1a3") will return 1 while calling float("1e3a2") will return 1000.0.