Skip to content

[Bug] Integer conversion raises ValueError: float too big #2905

Open

Description

@Debenben
print("small positive number:", 1e-40)
print("int conversion:", int(1e-40))

print("small negative number:", -1e-40)
print("int conversion:", int(-1e-40)) #ValueError: float too big

I would have expected it to return 0. I can use round() instead which is slightly slower, but the error looks like an unintended micropython feature.

Activity

  1. added
    triage
    on Nov 22, 2026
  2. laurensvalk commented on Nov 23, 2026

    @laurensvalk
    Member

    Thank you! Nice find. I can confirm this is a bug in mp_classify_fp_as_int.

    Since you found it, if you want to do the honors, you're welcome to report it there. If you do, please include a link there or here so we can find it.

    Otherwise no problem either and we'll submit it some time in the future.

  3. added
    software: pybricks-micropython
    topic: MicroPython
    and removed
    triage
    on Nov 23, 2026
  4. added theissue type on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    software: pybricks-micropythontopic: MicroPython

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions