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
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 survive string round-trip
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 that
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 problem with using max pos
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 1/100,000 vs. something
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.
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?"
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 res
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;
>
> say $rat-from
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 $rat-from-literal.S
10 matches
Mail list logo