[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] multiple NaN values



On 02/20/2012 08:01 AM, John Cowan wrote:
> Per Bothner scripsit:
>
>> IEEE 754 specifies multiple NaN values.  Scheme generally does
>> not care if there is a single value (bit pattern) for NaN,
>> or if there are multiple values:  If there are multiple NaN
>> values, or just one, they are all equivalent in terms of Scheme
>> computation.
>
> Added.
>
>> If there are multiple NaN values, they are all =.
>
> This is not the case: NaN is not = to any number, not even NaN.

Oops, indeed.  I wanted to convey something like "All combinations
of numerical operations must be the same as if all NaN values
are canicalized."

> [eqv?] is the subject of http://trac.sacrideo.us/wg/ticket/229 , which
> will be part of the upcoming fifth ballot.

The last comment seems incorrect.  You write:

> I confirmed that nan and nan2 expand to different bit patterns using
>Java's Double.doubleToRawLongBits method on the same system.

In Kawa nan and nan2 have the *same* bit-pattern (at least when run 
under JDK 1.7.0
on Fedora).  Thus as you'd expect eqv? returns #t.  I assume this would 
apply that
all/most Java-based Schemes, at least, so your experiment is meaningless.

$ kawa
#|kawa:1|# (define nan (/ 0.0 0.0))
#|kawa:2|# (define inf (/ 1.0 0.0))
#|kawa:3|# (define nan2 (- inf inf))
#|kawa:9|# (java.lang.Long:toHexString 
(java.lang.Double:doubleToRawLongBits nan))
fff8000000000000
#|kawa:10|# (java.lang.Long:toHexString 
(java.lang.Double:doubleToRawLongBits nan2))
fff8000000000000
#|kawa:11|# (define nan3 (java.lang.Double:longBitsToDouble 
#xfff8000000000001))
/dev/stdin:11:49: warning - integer 18444492273895866369 not in range of 
long
#|kawa:12|# nan3
NaN
#|kawa:13|# (nan? nan3)
#t
#|kawa:14|# (eqv? nan2 nan3)
#f
-- 
	--Per Bothner
per@x   http://per.bothner.com/

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports