Clean Singleton Docstrings
Marko Rauhamaa
marko at pacujo.net
Sat Jul 16 14:43:27 EDT 2016
Random832 <random832 at fastmail.com>:
> On Sat, Jul 16, 2016, at 03:27, Chris Angelico wrote:
>> Will an "Exact" non-integer be stored as Decimal or
>> Fraction? How do you know? They have vastly different semantics, and
>> you should be able to choose.
>
> Er, the point is for them to _not_ have different semantics. A decimal
> storage format would simply be an optimization for a fraction whose
> denominator is a power of 10 (or of 2 and 5)
>
> The semantics of the current Decimal class are those of an inexact
> number.
The most common use for Python's Decimal class is *exact* amounts of
currency.
The exactness of a number in Scheme is just a flag. You can force
exactness of a number literal with the #e or #i prefix:
(exact? #e1.2e-7)
==> #t # 1.2e-7 exactly
(exact? #i7)
==> #f # approximately 7
Marko
More information about the Python-list
mailing list