JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Representation of Integers and Reals Tutorial NaN
 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 negativeQNaN, if x is 0.0I'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:
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.
Internal Error