3 ms·
Misleading title is misleading... CPython rounds float values by converting them to string and then back
by science404 7y ago
Misleading title is misleading...
CPython rounds float values by converting them to string and then back
- duckerude 7y agoPyPy does it too: https://bitbucket.org/pypy/pypy/src/2fc0a29748362f2a4b99ab57aa551fc906878a6b/rpython/rlib/rfloat.py#lines-113 https://bitbucket.org/pypy/pypy/src/2fc0a29748362f2a4b99ab57... Jython instead uses BigDecimal::doubleValue: https://github.com/jythontools/jython/blob/b9ff520f4f65231209d5200c22724516a72e75f2/src/org/python/core/util/ExtraMath.java#L39 https://github.com/jythontools/jython/blob/b9ff520f4f6523120... But as another comment noted, BigDecimal::doubleValue can pull a similar trick: https://news.ycombinator.com/item?id=20818586 https://news.ycombinator.com/item?id=20818586