Message155059
| Author |
casevh |
| Recipients |
Amaury.Forgeot.d'Arc, Jim.Jewett, Ramchandra Apte, amaury.forgeotdarc, benjamin.peterson, casevh, ced, eric.smith, eric.snow, jjconti, mark.dickinson, pitrou, rhettinger, skrah, vstinner |
| Date |
2012年03月07日.08:30:00 |
| SpamBayes Score |
3.1801208e-09 |
| Marked as misclassified |
No |
| Message-id |
<1331109001.85.0.604470016125.issue7652@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I've found some differences between decimal and cdecimal.
cdecimal 2.3 does not support the __ceil__ and __floor__ methods that exist in decimal. math.ceil converts a cdecimal.Decimal instance into a float before finding the ceiling. This can generate incorrect results.
>>> import decimal
>>> import math
>>> math.ceil(decimal.Decimal("12345678901234567890.1"))
12345678901234567168
The decimal module in previous versions returns the correct answer 12345678901234567891
cdecimal.Decimal instances do not emulate the various single-underscore methods of a decimal.Decimal instance. In gmpy2, I use _int, _exp, _sign, and _is_special to convert a decimal.Decimal into an exact fraction. I realize the issue is with gmpy2 and I will fix gmpy2, but there may be other code that uses those methods. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年03月07日 08:30:02 | casevh | set | recipients:
+ casevh, rhettinger, amaury.forgeotdarc, mark.dickinson, pitrou, vstinner, eric.smith, benjamin.peterson, jjconti, ced, skrah, Amaury.Forgeot.d'Arc, eric.snow, Ramchandra Apte, Jim.Jewett |
| 2012年03月07日 08:30:01 | casevh | set | messageid: <1331109001.85.0.604470016125.issue7652@psf.upfronthosting.co.za> |
| 2012年03月07日 08:30:01 | casevh | link | issue7652 messages |
| 2012年03月07日 08:30:00 | casevh | create |
|