Besides, (x&|) is atomic and generalized to other bases: 10 1 0.1 |/ 321 32.1 3.21 0.321 0.0321 1 2.1 3.21 0.321 0.0321 0 0.1 0.21 0.321 0.0321 0 0 0.01 0.021 0.0321
> From: Rob Hodgkinson <[email protected]> > > Nothing, that would probably be my preferred choice too (Ric pointed > this out subsequently). > > I was just focusing on the real question of print precision - the same > print precision issue occurs for either approach. > > Note though that (- <.) performs faster albeit uses more space. > > dec1=:- <. > dec2=:1&| > 10{.z=:0.01*?100000$100000 > 318.72 415.11 155.08 826.2 664.99 381.41 148.83 758.18 562.25 117.54 > ts=: 6!:2 , 7!:2...@] > > 100 ts 'dec1 z' > 0.00573867950439 1573696 > 100 ts 'dec2 z' > 0.010124067688 1049472 > (dec1 -: dec2) z > 1 > > Thanks Oleg, Regards Rob > > On 03/05/2009, at 8:35 AM, Oleg Kobchenko wrote: > > > > > What's wrong with (1&|) ? > > > > > > ((- <.) -: 1&|) _5.1 _5.01 _0.0001 0 0.0001 5.1 5.2 5.0002 > > 1 > > > > > >> From: Rob Hodgkinson > >> > >> Alex, you may be asking 'too much print precision' on your display, > >> eg: > >> > >> decimal=:-<. > >> 9!:11 ]14 > >> > >> decimal 5.1 5.2 > >> 0.1 0.2 > >> 9!:11 ]15 > >> > >> decimal 5.1 5.2 > >> 0.0999999999999996 0.2 > >> 9!:11 ]16 > >> > >> decimal 5.1 5.2 > >> 0.09999999999999964 0.2000000000000002 > >> > >> You may need to use fmt (8!: x) to produce a specified format to > >> avoid > >> the system rounding display. > >> > >> Rob Hodgkinson > >> > >> > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/ > >> forums.htm > > > > > > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
