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.
Checking the stable version of the documentation...
float¶
Tipo real.
Descripción¶
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.
Tutoriales¶
Métodos¶
Descripciones de Métodos¶
Convierte un valor bool a un valor de real, float(true)
será igual a 1.0 y float(false)
será igual a 0.0.
Convierte un valor int a un valor de real, float(1)
será igual a 1.0.
Convierte un valor String a un valor de real. Este método acepta strings de reales como "1.23"
y strings de notación exponencial para su parámetro, de modo que al llamar a float("1e3")
devolverá 1000.0 y al llamar a float("1e-3")
devolverá 0.001. Llamar a este método con una string real inválida devolverá 0. Este método deja de analizar el primer carácter inválido y devolverá el resultado analizado hasta el momento, por lo que si se llama a float("1a3")
devolverá 1 mientras que si se llama a float("1e3a2")
devolverá 1000.0.