I've always thought this sort of information-hiding is one of the unappreciated strengths of these languages. However, it's good to be aware of this "domain extension" as it may be penalizing performance in something I'm looking at.
Thanks. On Thu, Jan 29, 2009 at 1:59 PM, Roger Hui <[email protected]> wrote: > 0. Since APL\360 from the 1960's, a number is a number is > a number, and the system strives to maintain the illusion that > the internal representation of a number does not matter. > > 1. 1e10 is a 64-bit floating point number, hence x: 1e10 is rational. > > 2. 1e9 is a 32-bit integer hence x: 1e9 is extended integer. > > 3. The monads # $ i. gives an extended integer result if > the argument is extended. This is so that some (most?) > computations involving extended arguments can stay > in the extended domain. e.g. > > +/i.1234567x > 762077221461 > > > > > ----- Original Message ----- > From: Devon McCormick <[email protected]> > Date: Thursday, January 29, 2009 10:42 > Subject: [Jprogramming] Extended integer extends to shape? > To: J-programming forum <[email protected]> > > > Members of the Forum - > > > > Do these cases seem odd? > > > > triNum=: ([:-:[:*/0 1+])"0 NB. triangular > > number by Gauss > > aa=. triNum x: > > 1e10 NB. ten-billionth > > triangular number > > > > 3!:0]aa NB. Type is "rational" > > 128 > > aa > > 50000000005000000000 > > aa=. triNum x: 1e9 NB. but > > billionth triangular number > > > > 3!:0]aa NB. is "extended integer". > > 64 > > ss=. > > $aa,aa NB. Even more oddly, > > > > 3!:0]ss NB. this shape is "extended integer". > > 64 > > ss=. <.0.5+*:%:ss NB. Force > > type to plain integer. > > 3!:0]ss > > 4 > > > > Why does an argument of "x: 1e10" give a rational result but a smaller > > argument is extended integer? > > More puzzling, why does the shape of an array of extended > > integers have the > > type "extended integer"? > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
