You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Improve documentation on is_nan() and NAN constant
This commit is contained in:
@@ -551,14 +551,14 @@
|
|||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<param index="0" name="x" type="float" />
|
<param index="0" name="x" type="float" />
|
||||||
<description>
|
<description>
|
||||||
Returns whether [param x] is a finite value, i.e. it is not [constant @GDScript.NAN], positive infinity, or negative infinity.
|
Returns whether [param x] is a finite value, i.e. it is not [constant @GDScript.NAN], positive infinity, or negative infinity. See also [method is_inf] and [method is_nan].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="is_inf">
|
<method name="is_inf">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<param index="0" name="x" type="float" />
|
<param index="0" name="x" type="float" />
|
||||||
<description>
|
<description>
|
||||||
Returns [code]true[/code] if [param x] is either positive infinity or negative infinity.
|
Returns [code]true[/code] if [param x] is either positive infinity or negative infinity. See also [method is_finite] and [method is_nan].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="is_instance_id_valid">
|
<method name="is_instance_id_valid">
|
||||||
@@ -579,7 +579,7 @@
|
|||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<param index="0" name="x" type="float" />
|
<param index="0" name="x" type="float" />
|
||||||
<description>
|
<description>
|
||||||
Returns [code]true[/code] if [param x] is a NaN ("Not a Number" or invalid) value.
|
Returns [code]true[/code] if [param x] is a NaN ("Not a Number" or invalid) value. This method is needed as [constant @GDScript.NAN] is not equal to itself, which means [code]x == NAN[/code] can't be used to check whether a value is a NaN.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="is_same">
|
<method name="is_same">
|
||||||
|
|||||||
@@ -277,7 +277,8 @@
|
|||||||
[b]Warning:[/b] Numeric infinity is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer number by [code]0[/code] will not result in [constant INF] and will result in a run-time error instead.
|
[b]Warning:[/b] Numeric infinity is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer number by [code]0[/code] will not result in [constant INF] and will result in a run-time error instead.
|
||||||
</constant>
|
</constant>
|
||||||
<constant name="NAN" value="nan">
|
<constant name="NAN" value="nan">
|
||||||
"Not a Number", an invalid floating-point value. [constant NAN] has special properties, including that [code]!=[/code] always returns [code]true[/code], while other comparison operators always return [code]false[/code]. This is true even when comparing with itself ([code]NAN == NAN[/code] returns [code]false[/code] and [code]NAN != NAN[/code] returns [code]true[/code]). It is returned by some invalid operations, such as dividing floating-point [code]0.0[/code] by [code]0.0[/code].
|
"Not a Number", an invalid floating-point value. It is returned by some invalid operations, such as dividing floating-point [code]0.0[/code] by [code]0.0[/code].
|
||||||
|
[constant NAN] has special properties, including that [code]!=[/code] always returns [code]true[/code], while other comparison operators always return [code]false[/code]. This is true even when comparing with itself ([code]NAN == NAN[/code] returns [code]false[/code] and [code]NAN != NAN[/code] returns [code]true[/code]). Due to this, you must use [method @GlobalScope.is_nan] to check whether a number is equal to [constant NAN].
|
||||||
[b]Warning:[/b] "Not a Number" is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer [code]0[/code] by [code]0[/code] will not result in [constant NAN] and will result in a run-time error instead.
|
[b]Warning:[/b] "Not a Number" is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer [code]0[/code] by [code]0[/code] will not result in [constant NAN] and will result in a run-time error instead.
|
||||||
</constant>
|
</constant>
|
||||||
</constants>
|
</constants>
|
||||||
|
|||||||
Reference in New Issue
Block a user