[Python-ideas] Python Float Update

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Jun 1 20:32:03 CEST 2015


On 01/06/2015 15:52, Joonas Liik wrote:
> Having some sort of decimal literal would have some advantages of its
> own, for one it could help against this sillyness:
>
>  >>> Decimal(1.3)
> Decimal('1.3000000000000000444089209850062616169452667236328125')
>
>  >>> Decimal('1.3')
> Decimal('1.3')
>
> I'm not saying that the actual data type needs to be a decimal (
> might well be a float but say shove the string repr next to it so it can
> be accessed when needed)
>
> ..but this is one really common pitfall for new users, i know its easy
> to fix the code above,
> but this behavior is very unintuitive.. you essentially get a really
> expensive float when you do the obvious thing.
>
> Not sure if this is worth the effort but it would help smooth some
> corners potentially..
>

Far easier to point them to 
https://docs.python.org/3/library/decimal.html and/or 
https://docs.python.org/3/tutorial/floatingpoint.html

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Python-ideas mailing list