From 70c0154cbee58d006107f8b4ca0e53b9dff553cc Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Wed, 18 Aug 2021 13:04:10 -0500 Subject: [PATCH] Improve the docs for the float type --- doc/classes/float.xml | 8 +++++++- doc/classes/int.xml | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/classes/float.xml b/doc/classes/float.xml index 60878eb0bd0..4bf04fe25f3 100644 --- a/doc/classes/float.xml +++ b/doc/classes/float.xml @@ -4,9 +4,13 @@ Float built-in type. - Float built-in type. + The [float] built-in type is a 64-bit double-precision floating-point number, equivalent to [code]double[/code] 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 [code]1.79769e308[/code], and the minimum is approximately [code]-1.79769e308[/code]. + Many methods and properties in the engine use 32-bit single-precision floating-point numbers instead, equivalent to [code]float[/code] 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 [code]float=64[/code] option. + 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 [method @GlobalScope.is_equal_approx] and [method @GlobalScope.is_zero_approx] methods instead of [code]==[/code] to compare [float] values for equality. + https://en.wikipedia.org/wiki/Double-precision_floating-point_format + https://en.wikipedia.org/wiki/Single-precision_floating-point_format @@ -231,11 +235,13 @@ + Returns the same value as if the [code]+[/code] was not there. Unary [code]+[/code] does nothing, but sometimes it can make your code more readable. + Returns the negative value of the [float]. If positive, turns the number negative. If negative, turns the number positive. With floats, the number zero can be either positive or negative. diff --git a/doc/classes/int.xml b/doc/classes/int.xml index 84a01aa0d0b..32b5fe10125 100644 --- a/doc/classes/int.xml +++ b/doc/classes/int.xml @@ -327,11 +327,13 @@ + Returns the same value as if the [code]+[/code] was not there. Unary [code]+[/code] does nothing, but sometimes it can make your code more readable. + Returns the negated value of the [int]. If positive, turns the number negative. If negative, turns the number positive. If zero, does nothing.