Infinity plus minus-infinity should be nan #1572

Open
opened 2023-12-03 19:52:01 -06:00 by dpgeorge · 0 comments
dpgeorge commented 2023-12-03 19:52:01 -06:00 (Migrated from github.com)

The pico-sdk handles inf - inf in __wrap___aeabi_fsub, and correctly returns nan.

But inf + (-inf) is not handled correctly and returns inf, when it should return nan. It looks like __wrap___aeabi_fadd needs to have similar handling to fsub to detect this case.

Reproduction in MicroPython with pico-sdk v1.5.1:

>>> inf = float("inf")
>>> inf + (-inf)
inf
>>> -inf + inf
inf

But with subtraction it's correct:

>>> inf - inf
nan
The `pico-sdk` handles `inf - inf` in `__wrap___aeabi_fsub`, and correctly returns `nan`. But `inf + (-inf)` is not handled correctly and returns `inf`, when it should return `nan`. It looks like `__wrap___aeabi_fadd` needs to have similar handling to fsub to detect this case. Reproduction in MicroPython with `pico-sdk` v1.5.1: ``` >>> inf = float("inf") >>> inf + (-inf) inf >>> -inf + inf inf ``` But with subtraction it's correct: ``` >>> inf - inf nan ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#1572
No description provided.