Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
NaN
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Operations generating NaN === There are three kinds of operations that can return NaN:<ref>{{cite web|url=http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.2736|author=David Goldberg|title= What Every Computer Scientist Should Know About Floating-Point|year=1991}}</ref> * Most operations with at least one NaN operand. * [[Indeterminate form]]s: ** The divisions {{math|(Β±0) / (Β±0)}} and {{math|(Β±β) / (Β±β)}}. ** The multiplications {{math|(Β±0) Γ (Β±β)}} and {{math|(Β±β) Γ (Β±0)}}. ** Remainder {{math|''x'' % ''y''}} when {{math|''x''}} is an infinity or {{math|''y''}} is zero. ** The additions {{math|(+β) + (−β)}}, {{math|(−β) + (+β)}} and equivalent subtractions {{math|(+β) − (+β)}} and {{math|(−β) − (−β)}}. ** The standard has alternative functions for powers: *** The standard {{code|pow}} function and the integer exponent {{code|pown}} function define {{math|[[zero to the power of zero|0<sup>0</sup>]]}}, {{math|1<sup>β</sup>}}, and {{math|β<sup>0</sup>}} as {{math|1}}. *** The {{code|powr}} function defines all three indeterminate forms as invalid operations and so returns NaN. * Real operations with [[complex number|complex]] results, for example: ** The square root of a negative number. ** The [[logarithm]] of a negative number. ** The [[Inverse trigonometric functions|inverse sine or inverse cosine]] of a number that is less than β1 or greater than 1. NaNs may also be explicitly assigned to variables, typically as a representation for missing values. Prior to the IEEE standard, programmers often used a special value (such as β99999999) to represent undefined or missing values, but there was no guarantee that they would be handled consistently or correctly.<ref name=idl/> NaNs are not necessarily generated in all the above cases. If an operation can produce an exception condition and traps are not masked then the operation will cause a trap instead.<ref>{{cite web |url=http://www.intel.com/products/processor/manuals/index.htm |title=Intel 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture |date=April 2008 |pages=118β125, 266β267, 334β335 }}</ref> If an operand is a quiet NaN, and there is also no signaling NaN operand, then there is no exception condition and the result is a quiet NaN. Explicit assignments will not cause an exception even for signaling NaNs.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)