Skip to content

Commit 6989a08

Browse files
committed
Merge pull request godotengine#105287 from Calinou/doc-gdscript-nan
Improve documentation on `is_nan()` and `NAN` constant
2 parents 8e2f5d0 + a0b7962 commit 6989a08

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

doc/classes/@GlobalScope.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,14 @@
551551
<return type="bool" />
552552
<param index="0" name="x" type="float" />
553553
<description>
554-
Returns whether [param x] is a finite value, i.e. it is not [constant @GDScript.NAN], positive infinity, or negative infinity.
554+
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].
555555
</description>
556556
</method>
557557
<method name="is_inf">
558558
<return type="bool" />
559559
<param index="0" name="x" type="float" />
560560
<description>
561-
Returns [code]true[/code] if [param x] is either positive infinity or negative infinity.
561+
Returns [code]true[/code] if [param x] is either positive infinity or negative infinity. See also [method is_finite] and [method is_nan].
562562
</description>
563563
</method>
564564
<method name="is_instance_id_valid">
@@ -579,7 +579,7 @@
579579
<return type="bool" />
580580
<param index="0" name="x" type="float" />
581581
<description>
582-
Returns [code]true[/code] if [param x] is a NaN ("Not a Number" or invalid) value.
582+
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.
583583
</description>
584584
</method>
585585
<method name="is_same">

modules/gdscript/doc_classes/@GDScript.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@
277277
[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.
278278
</constant>
279279
<constant name="NAN" value="nan">
280-
"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].
280+
"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].
281+
[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].
281282
[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.
282283
</constant>
283284
</constants>

0 commit comments

Comments
 (0)