Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

float

A built-in type for floating point numbers.

Description

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 maximum value of float is approximately 1.79769e308, and the minimum is approximately -1.79769e308.

Many 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 by default, but it can be changed to use 64-bit doubles if Godot is compiled with the precision=double option.

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

Tutorials

Constructors

float

float ( )

float

float ( float from )

float

float ( String from )

float

float ( bool from )

float

float ( int from )

Operators

bool

operator != ( float right )

bool

operator != ( int right )

Color

operator * ( Color right )

Quaternion

operator * ( Quaternion right )

Vector2