Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-14 Thread yary
I want an epsilon that doesn't confuse newbies and which also is efficient. epsilon=1/2**(mantissa bits-1) fits the bill. Why I want this- It would be great to have numbers survive round-trip conversions, when feasible. Specifically I have no need to compare Rats and Nums for equality, but I do

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-07 Thread Solomon Foster
On Sun, Mar 4, 2018 at 8:49 AM, yary wrote: > In that spirit, I'd expect numeric comparison in general, and epsilon > specifically, to be set so these return True: > > > pi == pi.Rat # Does Num to Rat conversion keep its precision? > False > > pi.Str.Num == pi # Does Num

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-04 Thread yary
The point of Rats is making Perl6 more correct and less surprising in common cases, such as $ perl6 > 1.1+2.2 3.3 > 1.1+2.2 == 3.3 True > 1.1+2.2 != 3.3 False vs any language using binary floating-point arithmetic DB<1> p 1.1+2.2 3.3 DB<2> p 1.1+2.2 == 3.3 DB<3> p 1.1+2.2 != 3.3 1 In

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-04 Thread Solomon Foster
On Sat, Mar 3, 2018 at 3:32 PM, yary wrote: > Or instead of 1/2**(32 or 64), re-asking these questions about epsilon: > > " Why so large? > >Why not zero? " > > What's justification for using 1/100,000 vs. something smaller vs. 0 "max > possible precision?" > The

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-03 Thread Brandon Allbery
Max precision rapidly becomes more memory requires than your computer has. On Sat, Mar 3, 2018 at 3:32 PM, yary wrote: > Or instead of 1/2**(32 or 64), re-asking these questions about epsilon: > > " Why so large? > >Why not zero? " > > What's justification for using

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-03 Thread yary
Still thinking this out. Does the default epsilon influence a Rat == Float comparison? If so, for that purpose, the most useful epsilon is one that maximizes its correctness.

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-03 Thread yary
Or instead of 1/2**(32 or 64), re-asking these questions about epsilon: " Why so large? Why not zero? " What's justification for using 1/100,000 vs. something smaller vs. 0 "max possible precision?"

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-03 Thread yary
Zeroing in on one point: > > A solution might be to instead provide a pragmatic, rather than > mathematical > > parameter: > > > > :$numbits = 64 > > > > This would say to keep as much precision as possible while making the > result > > fit in 64 bits. For example 2.147483647e0.Rat would

Re: (default) Real->Rat precision should match what compiler uses for literals

2018-03-03 Thread Brad Gilbert
On Fri, Mar 2, 2018 at 4:33 PM, Jim Avera wrote: > Hello, > > Using Rakudo 2018.01: > > my Rat $rat-from-literal = 1.23456789; > my Rat $rat-from-str = "1.23456789".Rat; > my Real $real = 1.23456789e0; > my Rat $rat-from-real= $real.Rat;

(default) Real->Rat precision should match what compiler uses for literals

2018-03-02 Thread Jim Avera
Hello, Using Rakudo 2018.01:     my Rat  $rat-from-literal = 1.23456789;     my Rat  $rat-from-str = "1.23456789".Rat;     my Real $real = 1.23456789e0;     my Rat  $rat-from-real    = $real.Rat;     say $rat-from-literal.nude; # (123456789 1)     say