[Python-Dev] PEP 327: Decimal Data Type
Stephen Horne
steve at ninereeds.fsnet.co.uk
Fri Jan 30 17:32:17 EST 2004
On Fri, 30 Jan 2004 07:06:21 -0800, Michael Chermside
<mcherm at mcherm.com> wrote:
>Facundo Batista writes:
>> I'm proud to announce that the PEP for Decimal Data Type is now published
>> http://www.python.org/peps/pep-0327.html
>
>VERY nice work here.
>
>Here's my 2 cents:
>
> (1) You propose conversion from floats via:
> Decimal(1.1, 2) == Decimal('1.1')
> Decimal(1.1, 16) == Decimal('1.1000000000000001')
> Decimal(1.1) == Decimal('110000000000000008881784197001252...e-51')
>
> I think that we'd do even better to ommit the second use. People who
>really want to convert floats exactly can easily write "Decimal(1.1, 60)". But
>hardly anyone wants to convert floats exactly, while lots of newbies would
>forget to include the second parameter. I'd say just make Decimal(someFloat)
>raise a TypeError with a helpful message about how you need that second
>parameter when using floats.
Good point. A 'DecimalExact' or similar function could perhaps be
provided to replace the simple conversion when people have really
thought about it and do really want it.
--
Steve Horne
steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list
mailing list