<div dir="ltr">Decimal literals are far from as obvious as suggested.  We *have* the `decimal` module after all, and it defines all sorts of parameters on precision, rounding rules, etc. that one can provide context for.  decimal.ROUND_HALF_DOWN is "the obvious way" for some users, while decimal.ROUND_CEILING is "the obvious way" for others.<div><br></div><div>I like decimals, but they don't simply make all the mathematical answers result in what all users would would consider "do what I mean" either.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 31, 2015 at 11:27 PM, Nicholas Chammas <span dir="ltr"><<a href="mailto:nicholas.chammas@gmail.com" target="_blank">nicholas.chammas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span class=""><blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:0px 0px 1.2em!important">I don’t know. Personally, I’d be willing to pay a performance penalty<br>to avoid reasoning about floating-point arithmetic most of the time,<br>then “drop into” floats when I need the speed.</p>
</blockquote>
</span><p style="margin:0px 0px 1.2em!important">This is perhaps a bit off topic for the thread, but +9000 for this.</p>
<p style="margin:0px 0px 1.2em!important">Having decimal literals or something similar by default, though perhaps problematic from a backwards compatibility standpoint, is a) user friendly, b) easily understandable, and c) not surprising to beginners. None of these qualities apply to float literals.</p>
<p style="margin:0px 0px 1.2em!important">I always assumed that float literals were mostly an artifact of history or of some performance limitations. Free of those, why would a language choose them over decimal literals? When does someone ever expect floating-point madness, unless they are doing something that is almost certainly not common, or unless they have been burned in the past?</p>
<p style="margin:0px 0px 1.2em!important">Every day another programmer gets bitten by <a href="http://stackoverflow.com/q/588004/877069" target="_blank">floating point stupidities like this one</a>. It would be a big win to kill this lame “programmer rite of passage” and give people numbers that work more like how they learned them in school.</p><span class="">
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:0px 0px 1.2em!important">The competing proposal is to treat decimal literals as decimal.Decimal values.</p>
</blockquote>
</span><p style="margin:0px 0px 1.2em!important">I’m interested in learning more about such a proposal. </p>
<p style="margin:0px 0px 1.2em!important">Nick</p>
<div title="MDH:Jmd0O8KgSSBkb24ndCBrbm93LiBQZXJzb25hbGx5LCBJJ2QgYmUgd2lsbGluZyB0byBwYXkgYSBw
ZXJmb3JtYW5jZSBwZW5hbHR5PGRpdj50byBhdm9pZCByZWFzb25pbmcgYWJvdXQgZmxvYXRpbmct
cG9pbnQgYXJpdGhtZXRpYyBtb3N0IG9mIHRoZSB0aW1lLDwvZGl2PjxkaXY+dGhlbiAiZHJvcCBp
bnRvIiBmbG9hdHMgd2hlbiBJIG5lZWQgdGhlIHNwZWVkLjwvZGl2PjxkaXY+PGJyPjwvZGl2Pjxk
aXY+VGhpcyBpcyBwZXJoYXBzIGEgYml0IG9mZiB0b3BpYyBmb3IgdGhlIHRocmVhZCwgYnV0ICs5
MDAwIGZvciB0aGlzLjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+SGF2aW5nIGRlY2ltYWwgbGl0
ZXJhbHMgb3Igc29tZXRoaW5nIHNpbWlsYXIgYnkgZGVmYXVsdCwgdGhvdWdoIHBlcmhhcHMgcHJv
YmxlbWF0aWMgZnJvbSBhIGJhY2t3YXJkcyBjb21wYXRpYmlsaXR5IHN0YW5kcG9pbnQsIGlzIGEp
IHVzZXIgZnJpZW5kbHksIGIpIGVhc2lseSB1bmRlcnN0YW5kYWJsZSwgYW5kIGMpIG5vdCBzdXJw
cmlzaW5nIHRvIGJlZ2lubmVycy4gTm9uZSBvZiB0aGVzZSBxdWFsaXRpZXMgYXBwbHkgdG8gZmxv
YXQgbGl0ZXJhbHMuPGJyPjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+SSBhbHdheXMgYXNzdW1l
ZCB0aGF0IGZsb2F0IGxpdGVyYWxzIHdlcmUgbW9zdGx5IGFuIGFydGlmYWN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GJyPjwvZGl2PjxkaXY+SSdtIGludGVyZXN0ZWQgaW4gbGVhcm5pbmcgbW9yZSBh
Ym91dCBzdWNoIGEgcHJvcG9zYWwuJm5ic3A7PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5OaWNr
PC9kaXY+" style="min-height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 1, 2015 at 2:03 AM Jim Witschey <<a href="mailto:jim.witschey@gmail.com" target="_blank">jim.witschey@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, May 31, 2015 at 11:46 PM, Matthias Bussonnier<br>
<<a href="mailto:bussonniermatthias@gmail.com" target="_blank">bussonniermatthias@gmail.com</a>> wrote:<br>
> IIRC (during | after) the language submit at PyCon this year, it was said that maybe the stdlib should get<br>
> less features, not more.<br>
<br>
Rationals (and Decimals) already exist in the standard library. The<br>
original proposal (as I read it, anyway) is more about the default<br>
interpretation of, e.g., integer division and decimal-number literals.<br>
<br>
> Side note, Sympy as a IPython ast-hook that will wrap all your integers into SymPy Integers and hence<br>
> give you rationals of whatever you like, if you want to SymPy-plify your life.<br>
<br>
Thank you for the pointer -- that's really cool.<br>
<br>
> But for majority of use will it be useful ?<br>
<br>
I believe interpreting "0.1" as 1/10 is more ergonomic than<br>
representing it as 1.600000023841858 * (2^-4). I see it as being more<br>
useful -- a better fit -- in most use cases because it's simpler, more<br>
precise, and more understandable.<br>
<br>
> What would be the performance costs ?<br>
<br>
I don't know. Personally, I'd be willing to pay a performance penalty<br>
to avoid reasoning about floating-point arithmetic most of the time,<br>
then "drop into" floats when I need the speed.<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div>