develooper Front page | perl.perl5.porters | Postings from August 2021

Re: Pre-RFC decimal data type

Thread Previous
Ovid via perl5-porters
August 5, 2021 09:34
Re: Pre-RFC decimal data type
Message ID:
Raku's rational numbers aren't quite the same thing. The square root of 2 isn't rational, but you could use decimals for saying "I only need X significant digits." You could do 2.sqrt.Rat.perl in Raku and you get 1393/985. I don't want that. I want arbitrary precision decimal numbers where I specify how many significant digits I want and not have to always carry a numerator and denominator around.
(I could be misunderstanding what happens on the Raku side)
Best,Ovid-- IT consulting, training, specializing in Perl, databases, and agile development 
Buy my book! - 

    On Thursday, 5 August 2021, 11:19:05 CEST, paul.marquess via perl5-porters <> wrote:  
 From: Nicholas Clark <> 
> On Thu, Aug 05, 2021 at 08:17:22AM +0000, Ovid via perl5-porters wrote:
> > Since we're talking about wishes, would a decimal type be interesting?
For example, in floating point, you can't represent .3. So the following
evaluates to false:
> > 
> > if ( 0 == .1 + .2 - .3 ) { ... }
> Yes, it would be interesting, but I have no good idea how to implement
this in a performant and portable way.

Use the Rational number implementation from Raku as inspiration? See


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About