On Fri, Sep 11, 2020 at 11:19:05AM -1000, David Mertz wrote:
On Fri, Sep 11, 2020 at 10:19 AM Guido van Rossum <guido@python.org> wrote:
While one may argue that writing `1e1000` is not an "arithmetic operation", certainly it's certainly not "casting strings to floats", and it's the simeplest way of producing `inf` in a pinch (in theory it's not portable, but I think "in a pinch" means you don't care about that).
I think that the only reason that could fail to produce inf is if your C doubles aren't IEEE-754 binary64. Are there any such platforms that are capable of building CPython but don't support IEEE-754? Or has anyone tried building CPython using, for example, posits instead?
For 128-bit versions of Python you'd need 1e4933. For 256-bit, 1e78914. But those work fine on 32-bit or 64-bit also.
Are there any Pythons with 128-bit or 256-bit floats? I've just tried Jython and IronPython, and got: >>> sys.float_info.max_10_exp 308L for both of them, which matches CPython. Micropython doesn't seem to support sys.float_info, but testing suggests that the floats are 64 bit too: # Micropython 1.9, Python version 3.4 >>> 1e309 inf If anyone is seriously worried about their Python supporting more than 64 bit floats, you can use 1e80000 which should give inf on any system supporting IEEE-754 no matter what size floats you have. What it will do on a posit or other non-IEEE-754 machine, I have no idea :-) -- Steve