Question about double #INF and #NAN
-
Does anyone understand the bit-wise representations of #INF and #NAN for the type double? Or could you point me to some real information on the internet? Also, what is the difference between Quiet NAN and Signaling NAN? I have been trying to find it with google all morning and I have found a lot of claiming to know but no actual knowledge. I know that for type float the bits are: 0x7FFFFFFF; // #NAN 0x7F800000; // #INF I believe that for type double the bits would: 0x7FFFFFFFFFFFFFFF; // #NAN 0x7FF0000000000000; // #INF However, this is just changing the exponent from 8 to 10 bits and assuming that if would be the same. I would feel much better if I could find some supporting documentation.
-
Does anyone understand the bit-wise representations of #INF and #NAN for the type double? Or could you point me to some real information on the internet? Also, what is the difference between Quiet NAN and Signaling NAN? I have been trying to find it with google all morning and I have found a lot of claiming to know but no actual knowledge. I know that for type float the bits are: 0x7FFFFFFF; // #NAN 0x7F800000; // #INF I believe that for type double the bits would: 0x7FFFFFFFFFFFFFFF; // #NAN 0x7FF0000000000000; // #INF However, this is just changing the exponent from 8 to 10 bits and assuming that if would be the same. I would feel much better if I could find some supporting documentation.
Isn't this [^] useful? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Isn't this [^] useful? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Yes, and thanks. But I'm still kind of looking for a nice table like they have for the 32 floats. Don't want to make the table myself because I'm not the expert. Just want to be able to refer to the expert.
-
Yes, and thanks. But I'm still kind of looking for a nice table like they have for the 32 floats. Don't want to make the table myself because I'm not the expert. Just want to be able to refer to the expert.
-
Yes, and thanks. But I'm still kind of looking for a nice table like they have for the 32 floats. Don't want to make the table myself because I'm not the expert. Just want to be able to refer to the expert.
If you're looking for
NAN
it may be either0xFFFM
or0x7FFM
i.e. sign bit may be either0
or1
and52
bit-wide mantissaM != 0
is implementation-dependent (may carry additional info). Of course this is going on my arrogant assumptions... :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
If you're looking for
NAN
it may be either0xFFFM
or0x7FFM
i.e. sign bit may be either0
or1
and52
bit-wide mantissaM != 0
is implementation-dependent (may carry additional info). Of course this is going on my arrogant assumptions... :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]The values in my original question are correct. (I believe) Just looking for supporting documentation. Thanks again for the time and thought you have put into this.
-
If you scroll up the page the nice table is there on the screen. [edit]sorry I note those are not doubles, but I'm sure a bit of simple extrapolation will do it[/edit]
Thanks. I was hoping to find such a table for double. Really, just a supporting documentation. I believe the values in my original question were correct.
-
The values in my original question are correct. (I believe) Just looking for supporting documentation. Thanks again for the time and thought you have put into this.
Well, while your values represent correctly
NAN
values, they (according to that Wikipedia page) don't cover all the possibilities. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Well, while your values represent correctly
NAN
values, they (according to that Wikipedia page) don't cover all the possibilities. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Sorry, I guess I didn't present that very well. NAN is an exponent of 0x7FF with a non-zero mantissa. INF is an exponent of 0x7FF with a zero mantissa. Here are the actual fuctions I am using... bool IsInf (double d) { const INT64 iInf = 0x7FF0000000000000; if ((*(INT64*)&d & 0x7FFFFFFFFFFFFFFF) == iInf) return true; return false; } bool IsNan (double d) { INT64 exp = *(INT64*)&d & 0x7FF0000000000000; INT64 mantissa = *(INT64*)&d & 0x000FFFFFFFFFFFFF; if (exp == 0x7FF0000000000000 && mantissa != 0) return true; return false; }
modified on Friday, November 27, 2009 3:04 PM