4 ms·
The source I had in my head as I was replying was https://posithub.org/docs/Posits4.pdf https://posithub.org/docs/Posits4.pdf pages 31/32 which implies that the
by bruce343434 4y ago
The source I had in my head as I was replying was https://posithub.org/docs/Posits4.pdf https://posithub.org/docs/Posits4.pdf pages 31/32 which implies that the sign bit is responsible for signalling-ness. Neither of these are a primary source however.
A random stackoverflow answer without sources seems to confirm your pov. Now I don't know what to believe. How is the sign bit used in NaNs? Would they really waste that bit?
- stephencanon 4y agoHi, former IEEE 754 committee member here: languages and architectures are allowed to choose how they encode signalingness, but they cannot use the sign bit to do it. The most common choice is to use the high-order but of the significand field, but most choices you might make is represented by some architecture.
- robocat 4y agoAwesome! So the important part of section 6.2.1 (2008) is the “should” is not a “must”? “A quiet NaN bit string should be encoded with the first bit (d1) of the trailing significand field T being 1. A signaling NaN bit string should be encoded with the first bit of the trailing significand field being 0.“ Or is it that some implementations before 2008 used other bits? PS: I might be complaining, but I do sincerely thank you for your hard work. I certainly would not want to be on a standards committee, so I sincerely appreciate the efforts of the committed whom fight so hard to make things better. Your comment just goes to show how many corner cases there are to the corner cases!!
- jcranmer 4y agoTraditionally, PPC used a different encoding of qNaN than, well, everybody else. PPC itself would later include a hardware mode that aligned to the more universal interpretation of qNaN.
- stephencanon 4y agoIIRC MIPS does the reverse of x86 and ARM too.
- jcranmer 4y agoSorry, you're right, it's MIPS that had the two encodings--PPC had the double-double type for long double that makes things "interesting." (It seems all architectures have their own unique floating-point weirdness).
- stephencanon 4y agoIt’s a “should”, hence recommended practice. Things required for conformance are “shall”.
- saagarjha 4y agoAnd I thought signaling NaNs were bad enough already…so you’re saying there’s no portable way of testing whether a bit pattern is going to signal if you operate on it without actually doing the operation? This is incredibly cursed :/
- stephencanon 4y agoThere’s the 754 (2008) isSignaling operation, bound to the issignaling macro in C, which makes it the platform owner’s problem instead of yours.
- saagarjha 4y agoIf only the platform owner provided this operation…
- jcranmer 4y ago> The source I had in my head as I was replying was https://posithub.org/docs/Posits4.pdf https://posithub.org/docs/Posits4.pdf pages 31/32 which implies that the sign bit is responsible for signalling-ness. Citing the person who came up with posits for anything related to IEEE 754 is a pretty poor decision, he is prone to a lot of misunderstanding here. There's a lot of decent explanations of IEEE 754 (including Wikipedia), so you shouldn't need to resort the explanations of someone whose major shtick is telling people IEEE 754 sucks. > How is the sign bit used in NaNs? Would they really waste that bit? Sign bits have no meaning for NaNs, although some C libraries (e.g., glibc) will distinguish between a NaN with the sign bit set and not set when printing floating-point numbers, which gives the illusion that it matters more than any other bit. Using the sign bit for qNaN-versus-sNaN is a bad idea from a design perspective, since there are a few FP operations explicitly specified to modify only the sign bit (fneg, fabs), and this would mean that you get regular operations that could generate sNaNs, which defeats the design goal of sNaN.
- stephencanon 4y agoSign bits of NaN is one of the dumbest parts of the 754 standard. 6.3 specifies that "the standard does not interpret the sign bit of a NaN" and then the very next sentence lists four cases where the sign bit of NaN has semantic meaning.
- adgjlsfhk1 4y agoreally all of the NaN behavior is really dumb. "we gave you enough different NaNs to uniquely represent every grain of sand on the planet uniquely" how does math work on them? "we have no idea" how do we tell what type of nan we have? "we have no idea" what should these bajillion values represent? "I don't know, probably something" the fact that they didn't just make there be a single NaN and make it equal to itself (and while you're at it make it so the real numbers have a total ordering)
- kryptiskt 4y agoBut in the end we found a great use case for all those NaN values because NaN-boxing is awesome.