develooper Front page | perl.perl6.language | Postings from March 2018

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

Thread Previous | Thread Next
From:
yary
Date:
March 3, 2018 20:28
Subject:
Re: (default) Real->Rat precision should match what compiler usesfor literals
Message ID:
CAG2CFAZ=Lw9AA5=5vdVCLvvZGEERxROgYxfayscK3U7NoyXfZA@mail.gmail.com
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 result in
> > 2147483647/1000000000 instead of 4310/2007.
>
> The Num type basically has a denominator which is based on 2s, not 10s.
>

The proposal is more-or-less expressible as having epsilon = 2/:numbits -
presuming that the numerator and denominator are about the same size.

From my POV the default epsilon is fine for practical use, but imprecise
enough to have this conversation come up repeatedly. Search this list for
"$epsilon = 1.0e-6 feels too big for Rat()"

How about setting the default epsilon to 1/2**32 or 1/2**64 and closing
that 2015 New Year's Eve post & this one too?

-y

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About