We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When we have a float we never know if it’s valid or NaN (not-a-number).
This makes math easy, as if you multiply or do other operations on a NaN the result will be NaN.
But sometimes we want to know that it is valid. To do this we could add special types that would then assert when receiving to check it matches.
defw set_speed(speed: F32.Finite) do @speed = speed end
F32.Finite
F32.Infinite
F32.NaN
F32.Normalized
F64
defmodule FloatChecker do def is_nan(<<_sign::1, 0xFF::8, mantissa::23-little>>) when mantissa != 0 do true end def is_nan(_), do: false end
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When we have a float we never know if it’s valid or NaN (not-a-number).
This makes math easy, as if you multiply or do other operations on a NaN the result will be NaN.
But sometimes we want to know that it is valid. To do this we could add special types that would then assert when receiving to check it matches.
F32.Finite
F32.Infinite
F32.NaN
F32.Normalized
F64
ChatGPT wrote this code to check whether a bitstring is NaN:
The text was updated successfully, but these errors were encountered: