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

Re: Pre-RFC decimal data type

Thread Previous | Thread Next
Ovid via perl5-porters
August 5, 2021 09:46
Re: Pre-RFC decimal data type
Message ID:
On Thursday, 5 August 2021, 10:29:29 CEST, Nicholas Clark <> 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?
Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About