1. J uses 64-bit floating point, so 4*a can be represented exactly. 2. If the exponent is big enough, the floating-point value will be an integer. It may not be the integer you wanted, but it can have only 54 or so bits of integer+fraction.
Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of John Randall > Sent: Monday, March 27, 2006 8:29 PM > To: Beta forum > Subject: RE: [Jbeta] x: 4 * !19 > > Henry Rich wrote: > > > >> -----Original Message----- > >> From: [EMAIL PROTECTED] > >> [mailto:[EMAIL PROTECTED] On Behalf Of John Randall > >> Sent: Monday, March 27, 2006 4:16 PM > >> To: Beta forum > >> Subject: Re: [Jbeta] x: 4 * !19 > >> > >> Henry: > >> > >> a=:!19 > >> 3!:0 a > >> 8 NB. floating point > >> b=:!x:19 > >> 3!:0 b > >> 64 NB. extended integer > >> > >> So in principle x: 4*a is rational, not an integer. > > > > I don't see how this follows. 4*a is a floating-point number > > which is exactly equal to 486580401635328000. When I convert > > that to exact, I could see that it might become a fraction > > equal to 486580401635328000, or it could become the integer > > 486580401635328000. > > Here it becomes a fraction that has some other value, which > > I don't understand. > > > > (I am on a 32-bit machine. Things may be different for 64 bits.) > > I don't see why a should be exactly an integer. If you > assume it has been > calculated in the most favorable manner, so that powers of 2 > can be moved > into the characteristic, it would still have a mantissa of > size 40, more > than the 23 bits allowed for IEEE 32-bit numbers, making exact > representation impossible. Whatever the details, x: !n is eventually > going to give a fraction. > > This is not necessarily bad unless you are relying on the internal > representation, which is hidden as much as possible. Consider > > a=:!19 > b=:! x: 19 > (4*a)=(4*b) > 1 > (4*a)=!.0(4*b) > 1 > x: 4*a > 33437550590372456995572480375r68719476736 > x: 4*b > 486580401635328000 > (>:4*a)=(4*a) > 1 > (>:4*b)=(4*b) > 0 > > Best wishes, > > John > > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
