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

Re: Pre-RFC decimal data type

Thread Previous
From:
Ovid via perl5-porters
Date:
August 5, 2021 09:34
Subject:
Re: Pre-RFC decimal data type
Message ID:
92404129.1921816.1628156078696@mail.yahoo.com
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 developmenthttp://www.allaroundtheworld.fr/. 
Buy my book! - http://bit.ly/beginning_perl 

    On Thursday, 5 August 2021, 11:19:05 CEST, paul.marquess via perl5-porters <perl5-porters@perl.org> wrote:  
 
 From: Nicholas Clark <nick@ccl4.org> 
> 
> 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
https://docs.raku.org/type/Rat

Paul

  
Thread Previous


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