Improve the docs for the float type

This commit is contained in:
Aaron Franke 2021-08-18 13:04:10 -05:00
parent de7b6d13eb
commit 70c0154cbe
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
2 changed files with 9 additions and 1 deletions

View file

@ -4,9 +4,13 @@
Float built-in type.
</brief_description>
<description>
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.
</description>
<tutorials>
<link title="Wikipedia: Double-precision floating-point format">https://en.wikipedia.org/wiki/Double-precision_floating-point_format</link>
<link title="Wikipedia: Single-precision floating-point format">https://en.wikipedia.org/wiki/Single-precision_floating-point_format</link>
</tutorials>
<methods>
<method name="float" qualifiers="constructor">
@ -231,11 +235,13 @@
<method name="operator unary+" qualifiers="operator">
<return type="float" />
<description>
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.
</description>
</method>
<method name="operator unary-" qualifiers="operator">
<return type="float" />
<description>
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.
</description>
</method>
</methods>

View file

@ -327,11 +327,13 @@
<method name="operator unary+" qualifiers="operator">
<return type="int" />
<description>
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.
</description>
</method>
<method name="operator unary-" qualifiers="operator">
<return type="int" />
<description>
Returns the negated value of the [int]. If positive, turns the number negative. If negative, turns the number positive. If zero, does nothing.
</description>
</method>
<method name="operator |" qualifiers="operator">