Skip to content

Floating-point behavior is not consistent with IEEE754 #4132

Closed
@Ecco

Description

@Ecco

For some reason, even the most simple floating-point operations yields results that don't match IEEE754. For instance, in uPy, 0.1+0.2 == 0.3 returns True, while it is False in CPython and every other programming language that uses IEEE754.

One might argue that uPy's behavior is better. In that case it might, but uPy also does some rounding errors, just not the same as everyone else… For example, 1000.4-1000 will yield 0.4000244 in uPy but 0.39999999999997726 in CPython, JavaScript (Chrome, Firefox), Ruby, etc…

Also it looks like uPy's behavior is not matching the Python standard, since https://docs.python.org/3/tutorial/floatingpoint.html explicitly says that 0.1+0.2 == 0.3 should return False.

This bug is reproducible on the uPy live web page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions