">>J has finite memory. Precise representation of an > irrational number using a rational representation > would require infinite memory.
Although it would be great if there was a switch to get "bignumber" extremely high precision that's not what I'm requesting here. I would like a switch that makes J either print the right digits or no digits at all. 61j59 ": x:!.0 %:2 1.41421356237309536751922678377013653516769409179687500000000 61j59 ": x: %:2 1.41421356237313909704121810319897219048636704119254805757362 from web, real answer 1.4142135623 7309504880 1688724209 6980785696 7187537694 Even with x:!.0 the 15th digit on is crap. At least, around the 50th digit on gets zero'ed out, so you at least have a clue that using expansion that high is not accurate. Basically I would like a switch that forces J to not print anything past the 15th digit if it won't be accurate. If the only benefit is teaching the user exactly where the lies begin, its a huge gain, as that beats loading the web and comparing digits side by side. >From a programming perspective it is very difficult to debug errors that occur on the 2^64th loop iteration. --- "Miller, Raul D" <[EMAIL PROTECTED]> wrote: > 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 > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
