[Python-ideas] Settable defaulting to decimal instead of float

Stephan Houben stephanh42 at gmail.com
Thu Jan 12 07:50:49 EST 2017


Hi Chris,

2017-01-12 13:17 GMT+01:00 Chris Angelico <rosuav at gmail.com>:
>
> Most of the time one of my students talks to me about decimal vs
> binary, they're thinking that a decimal literal (or converting the
> default non-integer literal to be decimal) is a panacea to the "0.1 +
> 0.2 != 0.3" problem.


Indeed. Decimal also doesn't solve the
1/3
issue.

I don't understand why people always talk about Decimal,
if you want math to work "right" you probably want fractions.

(With the understanding that this is for still limited value of "right".)


> Perhaps the real solution is a written-up
> explanation of why binary floating point is actually a good thing, and
> not just a backward-compatibility requirement?
>

I have sometimes considered writing up "Why the aliens of Epsilon Eridani,
whose computers use 13-valued logic, still use floating point numbers
with base 2."

(Short overview: analysis form first principles shows that the base should
be:
1. an integral number > 1 and
2. as small as possible (to minmax the relative rounding error))

The list of candidate bases satisfying these criteria is: 2.

Stephan


>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170112/a3341535/attachment-0001.html>


More information about the Python-ideas mailing list