> Another reason for my dislike of NaN.

This was not what I actually said when I saw the source
of the current problem.

The telephone company received a complaint that
linemen working in the neighborhood were using
foul language.  The district supervisor asked the
linemen to explain, and received the following report:
Joe and me were up on the pole when Joe dropped
his wrench on my head.  I said to him, "Really,
Joseph, you must handle your tools with more care."



----- Original Message -----
From: Roger Hui <[EMAIL PROTECTED]>
Date: Friday, February 1, 2008 13:30
Subject: Re: [Jbeta] J32 Windows hbeta available
To: Beta forum <[email protected]>

> The bug exposed by 2#_1e6 is one worth remembering for 
> telling your grandchildren.
> 
>    2#_1e6  NB. wrong
> _1000000 _475712
> 
> When moving sets of 8 bytes, there is a speed advantage 
> in moving them as 64 bit floats, so in doing n#_1e6 it is
> faster to move n%2 sets of 64 bits each set of which is
> 2 repetitions of _1e6 :
> 
>    3!:3 ] _1e6
> e1000000
> 04000000
> 01000000
> 00000000
> c0bdf0ff
> 
> But look what happens (in J602 gbeta or earlier):
> 
>    3!:3 ]2#_1e6
> e1000000
> 04000000
> 02000000
> 01000000
> 02000000
> c0bdf0ff
> c0bdf8ff
> 
> The c0bdf0ff (_1e6) got changed to c0bdf8ff (_475712).
> 
>    3!:3 ]_.
> e1000000
> 08000000
> 01000000
> 00000000
> 00000000
> 0000f8ff
> 
> It turns out that if you have a 64-bit pattern that looks like NaN,
> on some compilers (or different versions of the same compiler)
> the generated code quietly changes a bit from 0 to 1.  Another
> manifestation of the bug is as follows (in J602 gbeta or earlier):
> 
>    x=: 240 255{a.
>    y=: 8$x
>    y = 0 1 0 1 0 1 0 1 {x
> 1 1 1 1 1 1 0 1
> 
> We'd actually discovered this interesting "feature" at around 
> 2000, 
> but a recent compiler upgrade by one of us at Jsoftware exposed 
> the problem anew.  The situation is that in C, when x and y 
> are 
> doubles and you execute the C statement
>    x=y;
> it is possible for x and y to be not bit-by-bit identical.  
> 
> Another reason for my dislike of NaN.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to