JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
NaN | Reply
Hi,

I didn't really get the difference between QNaN and SNaN. sqrt(-1.0) gives QNaN but when do you get SNaN? And how do you check for them? Is it similar in Java? Java seems to have just one NaN.

And I was wondering, how do you do integer division with floating points? Or should that be floating point division?
Re: NaN (response to post by dskloet) | Reply
Maybe SNaN is what you get when you divide 0.0/0.0?

I think in Java, there's NaN, and there's Double.isNaN and Float.isNaN.

Integer division with floats - you can use floor on the result :-) Alternatively, you can cast the floats to ints and divide and cast back to a float (if your result was supposed to be that way).
Re: NaN (response to post by Kawigi) | Reply
Well, misof talks about integer division in the context of ?r ? 0 = ?∞ and such. So I don't think floor or casting make any sense.
Re: NaN (response to post by dskloet) | Reply
A SNaN is a concept defined by the IEEE standard. It is up to languages and/or compilers, whether and how they implement it.

In C++, if you divide a "double x;" by 0.0, the possible results are:
+inf, if x is positive
-inf, if x is negative
QNaN, if x is 0.0

I'm not really sure whether C++ implements SNaNs properly, I tend to think that it doesn't.

As of the "integer division" part of your posts, I really can't understand what are you trying to achieve. Maybe you could be more specific?
Re: NaN (response to post by misof) | Reply
As of the "integer division" part of your posts, I really can't understand what are you trying to achieve. Maybe you could be more specific?

Let me quote your tutorial:
<blockquote style="padding: 1em; background-color: lightgray;">The operations are defined in the probably most intuitive way. Any operation with a NaN yields a NaN as a result. Some other operations are presented in the table below. (In the table, r is a positive representable number, ∞ is Infinity, ? is integer division.)
Re: NaN (response to post by dskloet) | Reply
Now I understand :)

Of course, the word "integer" is a typo. (Strange, what was I thinking when I wrote that? :)) I meant normal floating point division, exactly as you suggested above.
Re: NaN (response to post by misof) | Reply
I fixed the tutorial.
RSS