Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

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(from: float)

float

float(from: String)

float

float(from: bool)

float

float(from: int)

Operators

bool

operator !=(right: float)

bool

operator !=(right: int)

Color

operator *(right: Color)

Quaternion

operator *(right: Quaternion)

Vector2

operator *(right: Vector2)

Vector2

operator *(right: Vector2i)

Vector3

operator *(right: Vector3)

Vector3

operator *(right: Vector3i)

Vector4

operator *(right: Vector4)

Vector4

operator *(right: Vector4i)

float

operator *(right: float)

float

operator *(right: int)

float

operator **(right: float)

float

operator **(right: int)

float

operator +(right: float)

float

operator +(right: int)

float

operator -(right: float)

float

operator -(right: int)

float

operator /(right: float)

float

operator /(right: int)

bool

operator <(right: float)

bool

operator <(right: int)

bool

operator <=(right: float)

bool

operator <=(right: int)

bool

operator ==(right: float)

bool

operator ==(right: int)

bool

operator >(right: float)

bool

operator >(right: int)

bool

operator >=(right: float)

bool

operator >=(right: int)

float

operator unary+()

float

operator unary-()


Constructor Descriptions

float</