Message78796
> Just for the avoidance of all doubt, do you mean the largest exponent
> with the number normalised to one digit to the right of the decimal
> place?
No. I'm using 'exponent' in the sense described in the standard. See:
http://speleotrove.com/decimal/dbover.html
Equivalently, it's the value of the _exp attribute for a Decimal
instance. (For the purposes of disambiguation, the alternative exponent
that you describe above is often referred to as the 'adjusted exponent'
in the documentation and code.)
Briefly, every finite Decimal can be thought of as a triple (sign,
coefficient, exponent), representing the value (-1)**sign * coefficient
* 10**exponent, with the coefficient an integer. It's this exponent
that should be maximized.
> Because 1e1 = 0.1e2 = 0.01e3 = ... and there is no "largest
> exponent possible"
All these have exponent 1:
>>> Decimal('1e1')._exp
1
>>> Decimal('0.1e2')._exp
1
>>> Decimal('0.01e3')._exp
1
IOW, leading zeros have no significance; only trailing zeros do.
> Also, why not just extend the Decimal() constructor to accept a float
> as the argument? Why have a separate from_float() method at all?
This was discussed extensively when the decimal module was being
proposed; see the Decimal PEP for arguments against this. |
|
Date |
User |
Action |
Args |
2009-01-02 14:09:36 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, steven.daprano |
2009-01-02 14:09:36 | mark.dickinson | set | messageid: <1230905376.02.0.82600617505.issue4796@psf.upfronthosting.co.za> |
2009-01-02 14:09:35 | mark.dickinson | link | issue4796 messages |
2009-01-02 14:09:34 | mark.dickinson | create | |
|