Skip to content

Use 0.0f/0.0f instead of math.h NAN#461

Closed
kainino0x wants to merge 1 commit intowebgpu-native:mainfrom
kainino0x:zero-over-zero
Closed

Use 0.0f/0.0f instead of math.h NAN#461
kainino0x wants to merge 1 commit intowebgpu-native:mainfrom
kainino0x:zero-over-zero

Conversation

@kainino0x
Copy link
Collaborator

@kainino0x kainino0x commented Dec 9, 2024

IEEE754-2008 says it produces a quiet NaN, so as long as the system has IEEE754 math this is fine.
OTOH if the system doesn't have NAN then math.h won't define it so this would produce a compilation error.

It compiles fine on Clang and GCC but MSVC produces a warning error:

error C2124: divide or mod by zero

The only reason to do this is to avoid including math.h. So I think the MSVC warning is enough reason to not make this change (just to make the header as warning-clean as possible, especially since this is in a macro currently).

EDIT: Oh, it's an error, not a warning, so really does not work. https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2124?view=msvc-170

Issue: #427

IEEE754-2008 says it produces a quiet NaN, so as long as the system has
IEEE754 math this is fine.

The only reason to do this is to avoid including math.h.

Issue: 427
@kainino0x kainino0x closed this Dec 9, 2024
@kainino0x kainino0x deleted the zero-over-zero branch December 9, 2024 21:30
@kainino0x kainino0x mentioned this pull request Dec 9, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant