Skip to content

correct representation of the maximum possible float64 #5471

Open
@99of9

Description

@99of9

Feature

Correct representation of the maximum possible float64.

When I run the following code in RustPython, it gives an "inf", but in CPython it gives the correct maximum possible float64. I ran into this on Wikifunctions (documented here https://www.wikifunctions.org/wiki/Talk:Z21420) where we use RustPython and are trying to correctly implement a new data type for float64.

exponent = int("1023")
significand = int("4503599627370495")
mantissa = 1 + significand/2**52
positive = 1
import math
val = math.ldexp(mantissa/2.0, exponent+1) * (1 if positive else -1)
print(str(val))

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions