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

Re: Pre-RFC decimal data type

Thread Previous | Thread Next
From:
Ovid via perl5-porters
Date:
August 5, 2021 09:46
Subject:
Re: Pre-RFC decimal data type
Message ID:
630517686.1929649.1628156759063@mail.yahoo.com
On Thursday, 5 August 2021, 10:29:29 CEST, Nicholas Clark <nick@ccl4.org> wrote:
 
 > 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.
I can't comment on portable, but as for performant, I don't think they can be as performant as floating point because you have to track how many significant digits you need (numbers automatically get zero padding) and with two decimals, compare the number of significant digits for each. However, you get developer performance and more correct code as a trade-off.

> > Fun fact: many COBOL-to-Java death marches have fallen down and not gotten back up because Java can't match COBOL's precision due to lacking COBOL's native decimal type (and simulating a Decimal type via classes meant that Java couldn't get the performance needed).>
> This I didn't know. Interesting. Thanks.

To be fair, many mainframes have hardware support for decimal numbers. That's a huge game changer.
Do GPUs?
Best,Ovid  
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