News for hackers. Stuff that matters.
Re:Modern Python Performance Considerations by dullcrisp on Thursday May 05, 2022 @01:52PM (#31276502)
Why would you want decimals for numeric computations though? Rationals might be useful for algebraic computations, but that’d be pretty niche. I’d think decimals would only be useful for presentation and maybe accountancy.
Re:Modern Python Performance Considerations by tomrod on Thursday May 05, 2022 @03:11PM (#31277316)
Well, for starters folks tend to code expecting 0.1+0.2=0.3, rather than abs(0.3-0.2-0.1) < tolerance_value

Raw floats don't get you there unfortunately.

Re:Modern Python Performance Considerations by dullcrisp on Thursday May 05, 2022 @07:43PM (#31279539)
If you want that you should use integers. This seems to be a misalignment of expectations rather than a fault in the language.

Other people have posted other examples but it’s not possible to represent real numbers losslessly in finite space. Mathematicians use symbolic computation but that probably is not what you would want for numerics. I could see a language interpreting decimal input as a decimal value and forcing you to convert it to floating point explicitly just to be true to the textual representation of the number, but it would just be annoying to anyone who wants to use the language for real computation and people who don’t understand floating point would probably still complain.

Edit: I’ll admit I have a pet peeve that people aren’t taught in school that decimal notation is a syntactic convenience and not an inherent property of numbers.

Re:Modern Python Performance Considerations by gjm11 on Thursday May 05, 2022 @03:56PM (#31277773)
They also expect 1/3 + 1/3 + 1/3 == 1. Decimals won't help with that.
Re:Modern Python Performance Considerations by kbenson on Thursday May 05, 2022 @04:14PM (#31277927)
That's slightly different in that most programmers won't read 1/3 as "one third" but instead "one divided by three", and interpret that as three divisions added together, and the expectations are different. Seeing a constant written as a decimal invites people to think of them as decimals, rather than the actual internal representation, which is often "the float that most closely represents or approximates that decimal".