On Sun, 09 Aug 2009, Joey K Tuttle wrote:
> At 13:36  -0700 2009/08/09, Roger Hui wrote:
> >J uses the C printf() routine to format 64-bit floating point
> >numbers.  The different outputs are perhaps due to the
> >differences in the printf()'s on the different systems.
> >In any case, only the first 16 decimal digits are significant;
> >the rest are garbage.
> >
> 
> "the rest are garbage." seems a little harsh. Especially in the case 
> of numbers that can be represented exactly in 64-bit floating point 
> e.g.
> 
>     40":"0 ]2^120+4*i.5     NB. 64 bit floats
>     1329227995784915872903807060280344576
>    21267647932558653966460912964485513216
>   340282366920938463463374607431768211456
> 5444517870735015415413993718908291383296
> ****************************************
> 
> which is identical on my systems to -
> 
>     40":"0 ]2^120+4*i.5x     NB. extended integers
>     1329227995784915872903807060280344576
>    21267647932558653966460912964485513216
>   340282366920938463463374607431768211456
> 5444517870735015415413993718908291383296
> ****************************************
> 
> versus
> 
>     40":"0 ]2^120+4*i.5  
>     1329227995784915900000000000000000000
>    21267647932558654000000000000000000000
>   340282366920938460000000000000000000000
> 5444517870735015400000000000000000000000
> ****************************************
> 

Actually I like window's printf for this particular case.  Once a
number is represented in ieee format, it can not know whether it is
an exact 64-bit floating point or just an approximation of another
decimal number.  The padding zero can give more predictable output.
Suppose a delta is added to these numbers


   40":"0 ]2^120+4*i.5
   1329227995784915872903807060280344576
  21267647932558653966460912964485513216
 340282366920938463463374607431768211456
5444517870735015415413993718908291383296
****************************************

   40":"0 ] 1234567 + 2^120+4*i.5
   1329227995784915872903807060280344576
  21267647932558653966460912964485513216
 340282366920938463463374607431768211456
5444517870735015415413993718908291383296
****************************************


-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to