Talk:NaN
This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||
|
IEEE
[edit]How much of the modern NaN (ie the IEEE standard one) was innovation by the standard committee? I would expect at least the spelling "NaN" and the distinction between singalling and quiet NaN to be from the IEEE standard...
Pronunciation
[edit]Is NaN an acronym or an initialism? jnestorius(talk) 20:52, 21 September 2006 (UTC)
- Yes. Uncle G 12:10, 14 December 2006 (UTC)
- Dunno, but she sure is getting old.
- NaN = Not a Number. Anthony Appleyard (talk) 15:04, 2 August 2009 (UTC)
- Yes,NaN=Not a Number 2600:8800:8380:350:ECFB:E562:9508:7478 (talk) 15:34, 6 October 2023 (UTC)
- Ones I know pronounce it as a word (nan), or say the whole thing (not a number). Gah4 (talk) 01:34, 7 October 2023 (UTC)
Nullity/Transreal numbers
[edit]- Since AfD went through on the Transreal number article to redirect to here, should we add a mention of it? Someone looking up transreal numbers and just getting this article would be confused, since there's no way they know how they relate. fintler 23:06, 14 December 2006 (UTC)
- Transreal number currently redirects to a section of James A. D. W. Anderson. This appears to be used nowhere and the only sources are James A. D. W. Anderson's own papers (BTW, this has never been mentioned in the discussions in the stds-754 list). So this is original research, and I've just removed the sentence that was added in the mean time. — Vincent Lefèvre (talk) 14:19, 11 August 2023 (UTC)
Number vs Numeral
[edit]- In the paragraph dealing with the NaN Toolbox, the word numeral is used several times. Should this read number instead? 67.168.55.79 16:31, 19 April 2007 (UTC)
Canonical NaNs
[edit]I've had a lot of cross-platform experience with NaNs back in the 1990's. As the current article suggests, all the big h/w vendors fell into one of the two possible camps regarding the representation of signalling and quiet NaNs (basically a difference in interpretation of one bit). This affected data portability but worse still was the situation with private NaN values. The product I worked on then used several private encodings to represent special numeric cases, e.g. uninitialised, error, not-available, etc. Some were quiet and some were signalling. All architectures should have one special quiet NaN representing arithmetic calculations with no valid (real) answer, e.g. 0/0, sqrt(-1), log(0), etc., when trapping is suppressed. In the Intel architecture, this is called 'Indefinite'. A better description is the 'Canonical NaN' -- I cannot give a reference for this term but I believe I first saw it in some old DEC internal documentation. Unfortunately, different vendors used different encodings for this special value and so trying to make your own private encodings distinct from it was like trying to hit a moving target. Even more unfortunate was the fact that some vendors used a different value in their h/w to in their mathematics library, and at least one vendor used a different encoding in different versions of their h/w chipset.
Another issue was the way in which NaNs (and Infinities) were generated on some machines. Rather than being generated by h/w, or even f/w, some generated a microtrap that then dispatched to a piece of s/w to determine the correct value to return from the floating-point instruction. This could result in a calculation that generated a special value taking 50-100 times longer than one that generated a normal value. This affected several database products of that era, and especially OLAP products, since it was more efficient to just ignore IEEE special values altogether and select some arbitrary 'large real values' to represent the special cases instead (e.g. 1E38). --TonyP (talk) 19:58, 8 April 2009 (UTC)
Pless admision my seet no E027086 maths no 20 plees 35
Satyaprakash rajbhar (talk) 11:33, 24 June 2017 (UTC)
- I do not understand that. I removed the edit, there was no reason for it that I could see and it seems strange. Dmcq (talk) 11:47, 24 June 2017 (UTC)
Zero divided by Zero
[edit]In some cases, NaN is used where numbers may be results. For example, zero divided by zero is ambiguous -- any number multiplied by zero is zero, so zero divided by zero may be any number. In this context, "Not a Number" is an inaccurate description of the result. A more accurate description of this case would be "Not Any Specific Number" or, more simply "Any Number". —Preceding unsigned comment added by 159.54.131.7 (talk) 17:08, 9 September 2009 (UTC)
Bubbles on beach
[edit]Mere coincidence that Patrick Mc in The Prisoner: "I am not a number" —Preceding unsigned comment added by 82.19.170.119 (talk) 17:27, 3 October 2009 (UTC)
- In the original script, he was going to say "I am an arithmetic overflow," but the director liked "not a number" better. Jmdeur (talk) 18:02, 9 November 2009 (UTC)
Unicode symbol?
[edit]I'm looking for the unicode symbol if any that is NaN in a single codepoint. Help? 168.251.194.25 (talk) 19:50, 16 December 2009 (UTC)
- What is the purpose? What's wrong with using 3 separate letters N, a and N again? 2A01:119F:21D:7900:55BF:CA37:B0A2:86E5 (talk) 18:47, 10 August 2018 (UTC)
- There does not appear to be any Unicode symbol for NaN; here's the search. +mt 21:55, 12 August 2018 (UTC)
1/0 is NaN?
[edit]The article says that "For example, 1/0 is undefined as a real number, and so represented by NaN". However, at least in Java, 1/0.0=POSITIVE_INFINITY, not NaN (and 1/-0.0=NEGATIVE_INFINITY, but 0/0.0 is NaN). —Preceding unsigned comment added by 81.20.159.197 (talk) 14:11, 29 January 2010 (UTC)
- Yes that's very silly, I've gone and replaced it with 0/0. Dmcq (talk) 17:28, 29 January 2010 (UTC)
- 09975934044 202.165.90.36 (talk) 18:59, 15 November 2024 (UTC)
∞^0 omitted?
[edit]is listed in Indeterminate form#List of indeterminate forms. Why is it not listed in the list of operations that return an NaN, while is listed? --71.141.115.178 (talk) 20:26, 18 June 2010 (UTC)
- I better check the article through for the power function. In fact IEEE 754-2008 has 3 different power operations. The usual one is pow() which tries returning a value rather than a NaN, pow(1,∞) is 1 but powr(1,∞) is an invalid operation and so return NaN. Dmcq (talk) 22:47, 18 June 2010 (UTC)
Tan(pi/2)
[edit]Uh... tan(pi/2) is not complex. Should this bullet point be moved into the second of the three categories (in the Creation section)?
- I haven't the foggiest what whoever put that inmust have been thinking of. I think the line should just be completely removed. tan never returns NaN except for infinity or NaN arguments so it is pretty well behaved. In fact I'll just go and remove it now thanks. 19:45, 17 July 2010 (UTC)
Indeterminate
[edit]According to IEEE-754 References, there is a special value *Indeterminate*. It's hard to find any useful information on it. From what little I can tell, it might be a subset of NaN, used specifically for "indeterminate forms". It would be good to properly explain that special value, and how it is the same/differs from NaN. Cmcqueen1975 (talk) 03:18, 12 October 2010 (UTC)
- The missing reference there is [1]. There is no special 'indeterminate' value but he gives a useful way of thinking about sNaN and qNaN. Dmcq (talk) 09:32, 12 October 2010 (UTC)
trigonometric and inverse trigonometric functions
[edit]Worth remembering:
1. Trigonometric functions tan (2x+1)π/2, csc (2x+1)π/2, cot 2πx, and sec 2πx in which x is an integer imply division by zero and thus give only infinite results.
2. Some trigonometric functions have limited ranges for their values:
-1 ≤ sin x ≤ 1 -1 ≤ cos x ≤ 1 |sec x| ≥ 1 |csc x| ≥ 1
Inverse trigonometric functions that have x inappropriate for those ranges, including arcsin x > 1, arccos x > 1, -1 < arcsec x < 1, and -1 < arccsc x < 1 can have no values.
Calculators obviously give non-numbers for prohibited values for those functions. Pbrower2a (talk) 14:22, 1 February 2013 (UTC)
Languages that use NaN
[edit]Would it be relevant to include a list of languages that use NaNs? This section could also include the representation used, which could give more context to the Display section. Paul2520 (talk) 15:43, 7 November 2013 (UTC)
Hardware
[edit]and in practice are raised as hardware-level exceptions by the CPU.[1] Seems to me that most hardware generates an exception for fixed point divide by zero, but the exception for fixed point overflow is rare. Converting floating point to integer for out of range values might be considered fixed point overflow. Unless all hardware generates an exception, the statement is wrong. Gah4 (talk) 20:56, 2 October 2015 (UTC)
- I removed the sentence earlier today. There are no signals for overflow either, so that the GNU libc manual is wrong. On x86, I get -2147483648 even for positive overflow. But I have results of tests done by Bill Allombert in 2004, which show that each processor had its own behavior (never a signal, but different values). Hence the choice of a undefined behavior in C. Vincent Lefèvre (talk) 21:14, 2 October 2015 (UTC)
- For x86, I believe for x>=0, you need an INTO instruction after any instruction you want to trap for overflow. This does an INT 4 if the OF flag is set. I believe, though, that divide by zero interrupt happens without a special instruction. (In the MS-DOS days, there were some interrupts used by MSDOS and/or the BIOS that conflicted with some processor hardware interrupts. Intel reserved the first 32, but people used them anyway. Gah4 (talk) 23:41, 2 October 2015 (UTC)
What uses or generates sNaNs?
[edit]On the topic of signaling NaN, article says "There have been several ideas for how these might be used:" ... "In practice this approach is faced with many complications". As far as I can tell, nobody has ever successfully used signaling NaNs for anything (and most environments disable them by default). If this is true, perhaps the article should say more a little clearly that almost nobody ever uses or encounters signaling NaNs? Or, if it's false, the article could mention an example of a product/project/technology which uses them. 50.197.188.73 (talk) 06:05, 1 December 2015 (UTC)
User-defined NaNs
[edit]I would like to recommend that the main contributors to this page add a section on the use of user-defined NaN values. There are clear application requirements that would benefit from the apparent freedom offered by IEEE for user-defined NaN states, but there are serious practical difficulties involved (see my earlier entry on this Talk page). Having a section that makes people aware of those difficulties, any best practices, and potential revisions to the standard, would be a useful resource for application designers.TonyP (talk) 11:19, 17 November 2018 (UTC)
- Wikipedia requires WP:Reliable sources describing the situation. It doesn't sound to me like there is much on it otherwise the situation wouldn't be in the mess you describe. Have you seen anything that could be cited?? Dmcq (talk) 12:09, 17 November 2018 (UTC)
- There should be a section on the payload, though, with the mention of NaN-boxing in particular (as on IEEE 754). Vincent Lefèvre (talk) 12:16, 17 November 2018 (UTC)
- Added some stuff on NaN-boxing using Robert Nystorm's book on interpreters. Also added some words on canonical NaN, which commonly goes together with NaN-boxing: the system is already using the payload for something else, so you get fewer choices for the payload; in fact, why not just one "canonical" choice? Artoria2e5 🌉 03:51, 25 February 2024 (UTC)
- "Canonical NaN" is already used by IEEE 754 to mean "canonical encoding of a NaN" (e.g. "isCanonical(x) is true if and only if x is a finite number, infinity, or NaN that is canonical." page 38, but also for totalOrder page 42). So "canonical NaN" should not be used on WP with a different meaning. I've added a {{Confusing}} template on this new "Canonical NaN" section. — Vincent Lefèvre (talk) 02:57, 26 February 2024 (UTC)
- Added some stuff on NaN-boxing using Robert Nystorm's book on interpreters. Also added some words on canonical NaN, which commonly goes together with NaN-boxing: the system is already using the payload for something else, so you get fewer choices for the payload; in fact, why not just one "canonical" choice? Artoria2e5 🌉 03:51, 25 February 2024 (UTC)
- Good point! I have had several conversations in the past with CTOs of other products in the database field, and they all had the same view on NaNs for application usage: look OK on paper but no good in practice for CPU-intensive products or where cross-platform compatibility is important. The issue with a particular provider's chipsets differing from each other, and differing from the associated mathematics library, was under Solaris/SPARC. In principle, the old manuals could be cited but you'd need a range in order to make the points (I have only one copy). It's in the nature of commercial software development that you don't normally publish your problems or weaknesses so there won't be much written on this. This is probably an excellent example of wikipedia's policy being too much of a straightjacket, and not capturing the reality of the situation. Maybe you could use a different tack: it is clear (and documented) that encodings for the "canonical NaN" differ between different platforms -- making it hard to avoid them when defining encodings for application usage -- and also for the quiet/signalling convention. That should be enough to infer repercussions for s/w development. The performance differential -- which was probably at its worst on the DEC Alpha h/w -- is harder to cite. Is there any way that the main page can refer to the Talk page?TonyP (talk) 13:41, 17 November 2018 (UTC)
- There should be a section on the payload, though, with the mention of NaN-boxing in particular (as on IEEE 754). Vincent Lefèvre (talk) 12:16, 17 November 2018 (UTC)
- After searching, I found several reports on operand-dependent performance anomalies in FPUs. In particular, That’s Not Normal–the Performance of Odd Floats mentions "Even today, on a SandyBridge processor, the x87 FPU causes a slowdown of about 370 to one on NaNs and infinities". Other reports have mentioned "two orders of magnitude" difference. This supports my claims above, and hence the repercussions to FPU-intensive applications that need to use infinities or application-defined NaN states.TonyP (talk) 10:29, 18 November 2018 (UTC)
- randomascii is a blog but judging by references to it elsewhere I believe it is admissible as written by an expert under WP:SELFSOURCE. Dmcq (talk) 10:43, 18 November 2018 (UTC)
- After searching, I found several reports on operand-dependent performance anomalies in FPUs. In particular, That’s Not Normal–the Performance of Odd Floats mentions "Even today, on a SandyBridge processor, the x87 FPU causes a slowdown of about 370 to one on NaNs and infinities". Other reports have mentioned "two orders of magnitude" difference. This supports my claims above, and hence the repercussions to FPU-intensive applications that need to use infinities or application-defined NaN states.TonyP (talk) 10:29, 18 November 2018 (UTC)
Function definition - unclear sentence
[edit]In the Function definition section one sentence reads:
"The rationale for returning the value 1 for the indeterminate forms was that the value of functions at singular points can be taken as a particular value if that value is in the limit the value for all but a vanishingly small part of a ball around the limit value of the parameters."
Seems unclear to me, two comments: "if that value is in the limit the value" should that say "if that value is in the limit of the value"? Also what does "part of a ball around the limit value" mean please? John a s (talk) 16:51, 27 December 2021 (UTC)
- I agree that this is unclear. And this needs a source, because this is not the rationale for ISO C. — Vincent Lefèvre (talk) 17:54, 27 December 2021 (UTC)
- This mainly comes from change 345227754 done in 2010 by Dmcq, saying: The IEEE 754 standard says that the value of functions at singular points can be taken as a particular value if that value is in the limit the value for all but a vanishingly small part of a ball around the parameters. But this does not seem to be true. I don't see where the IEEE 754 standard says anything like that. — Vincent Lefèvre (talk) 18:19, 27 December 2021 (UTC)
- Ball is used for limits in the complex case. Otherwise I don't understand the question. Gah4 (talk) 18:22, 27 December 2021 (UTC)
- The power function (used in the context) has 2 arguments. Hence the term "ball". — Vincent Lefèvre (talk) 18:40, 27 December 2021 (UTC)
- Thanks, can you provide an example computer language and function where the term ball is used please? Sorry I'm not a computer programmer, and Google only gives me examples of how to model a physical ball. Also the word ball doesn't appear anywhere else in the NaN article, or the IEEE 754 article, or in the IEEE 754 spec itself. John a s (talk) 18:50, 28 December 2021 (UTC)
- The term "ball" is used in Arb - a C library for arbitrary-precision ball arithmetic, for instance. This comes from the notion of ball in topological spaces. — Vincent Lefèvre (talk) 19:36, 28 December 2021 (UTC)
- Thanks for the clarification! I found this https://www.texmacs.org/joris/ball/ball.html explaining the use of balls quite helpful too. This just leaves my first comment about the sentence to be worked on.John a s (talk) 23:11, 28 December 2021 (UTC)
- The term "ball" is used in Arb - a C library for arbitrary-precision ball arithmetic, for instance. This comes from the notion of ball in topological spaces. — Vincent Lefèvre (talk) 19:36, 28 December 2021 (UTC)
- Thanks, can you provide an example computer language and function where the term ball is used please? Sorry I'm not a computer programmer, and Google only gives me examples of how to model a physical ball. Also the word ball doesn't appear anywhere else in the NaN article, or the IEEE 754 article, or in the IEEE 754 spec itself. John a s (talk) 18:50, 28 December 2021 (UTC)
- The power function (used in the context) has 2 arguments. Hence the term "ball". — Vincent Lefèvre (talk) 18:40, 27 December 2021 (UTC)
- Ball is used for limits in the complex case. Otherwise I don't understand the question. Gah4 (talk) 18:22, 27 December 2021 (UTC)
- This mainly comes from change 345227754 done in 2010 by Dmcq, saying: The IEEE 754 standard says that the value of functions at singular points can be taken as a particular value if that value is in the limit the value for all but a vanishingly small part of a ball around the parameters. But this does not seem to be true. I don't see where the IEEE 754 standard says anything like that. — Vincent Lefèvre (talk) 18:19, 27 December 2021 (UTC)
Comparison
[edit]I think the case NaN = NaN resulting in false should be mentioned at least. 132.199.174.208 (talk) 13:07, 10 January 2022 (UTC)
- It is in: NaN#Comparison_with_NaN but written in a confusing way. Well, it almost makes sense if you read the article from top to bottom, but if you just wanted to know that, you could be surprised. The article pretty much covers the IEEE-754 version, though maybe there aren't others. Even more, using IEEE floating point format doesn't mean that an implementation follows all the IEEE rules, such as for NaN. Even more, though, one should be careful and use isNaN() instead of a test for equality. An optimizing compiler might optimize the test away. Gah4 (talk) 19:45, 10 January 2022 (UTC)
- I've just partly rewritten this section to attempt to clarify. Note also that nowadays, compilers are normally aware of IEEE 754, thus do not optimize such tests unless told to do so. — Vincent Lefèvre (talk) 22:09, 10 January 2022 (UTC)
- Looks a lot better. I think I used to believe that ≠ also returned false, but I don't know that I ever saw it written either way. OPtimizers are always funny, though. If you make it obvious enough, I hope they figure it out. Otherwise, maybe not. Gah4 (talk) 23:38, 10 January 2022 (UTC)
- My old favorite for optimizers comes from an actual IBM manual (50 years ago):
- I've just partly rewritten this section to attempt to clarify. Note also that nowadays, compilers are normally aware of IEEE 754, thus do not optimize such tests unless told to do so. — Vincent Lefèvre (talk) 22:09, 10 January 2022 (UTC)
DO 11 I=l,10
DO 12 J=l,10
IF (B(I).LT.0.)GO TO 11
12 C(J)=SQRT(B(I))
11 CONTINUE
where the compiler moves the SQRT, but not the test, outside the loop. Gah4 (talk) 23:57, 10 January 2022 (UTC)
N/A
[edit]A recent edit summary mentions N/A. As well as I know, some statistics software uses NaN for what in statistics is N/A. For example, missing data in an input data set, as it was never measured. That should be different from NaN, and maybe other bits are used to distinguish them. Gah4 (talk) 07:08, 18 March 2024 (UTC)
- Perhaps, but the goal of the {{Distinguish}} template (removed by the edit in question) is "to point out to our readers the existence of one or more articles whose title(s) is, or are, similar to the page in question". So this is unrelated to the fact NaN can be used for N/A. The question is whether "NaN" is similar to "N/A", with a possible confusion by the reader. IMHO, there are more differences than similarities. — Vincent Lefèvre (talk) 00:05, 19 March 2024 (UTC)