p j wrote: > The main problem, > cf x: %: 2 > 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 45 2 1 2 11 1 3 6 > cf x:!.0 %: 2 > 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 1 4 2 5 9 > 3 3 1 11 57 2
Why is this a problem? J has finite memory. Precise representation of an irrational number using a rational representation would require infinite memory. Which is why we get rational approximations as results from functions which we think of as irrational: %: 2 1.41421 x: %: 2x 431273813145r304956637823 It's also possible to look at the gory internal details of these numbers. 3!:3 %: 2 e1000000 08000000 01000000 00000000 cd3b7f66 9ea0f63f %: 2 is represented as an ieee floating point number. But, perhaps, the numeric headers are distracting: hexRepresentation=: (#3!:3 i.0) ,@}. 3!:3@, hexRepresentation %:2 cd3b7f669ea0f63f On the other hand: hexRepresentation x:%:2x 1c0000003c000000e100000004000000030000000100000003000000490c0000d51c0000d8100000e1000000040000000300000001000000030000008f1e00001f160000e90b0000 431273813145r304956637823 is represented using what looks like a pair of numeric vectors of some sort. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
