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
num_traits::Float
There are a couple of occasions where I regularly have to add an additional num_traits::Float bound.
Methods I need from num_traits::Float include the following:
min_positive_value
is_nan
nan
infinity
neg_infinity
max
min
NaN
copysign
Is the RealField suitable for these methods or is it intended to be more abstract, i.e., it not necessarily represents these floating point semantics?
RealField
The text was updated successfully, but these errors were encountered:
For what it is worth, here is what I am using for is_nan to avoid adding this bound:
#[inline] fn is_nan<R: RealField>(x: R) -> bool { let zero = R::zero(); if x < zero { false } else { if x >= zero { false } else { true } } }
Sorry, something went wrong.
same but more succinct
#[inline] fn is_nan<R: RealField>(x: R) -> bool { x.partial_cmp(&R::zero()).is_none() }
Thanks @lelongg . Also clippy does not complain about your version.
No branches or pull requests
There are a couple of occasions where I regularly have to add an additional
num_traits::Float
bound.Methods I need from
num_traits::Float
include the following:min_positive_value
is_nan
nan
infinity
andneg_infinity
max
andmin
with theNaN
semanticscopysign
Is the
RealField
suitable for these methods or is it intended to be more abstract, i.e., it not necessarily represents these floating point semantics?The text was updated successfully, but these errors were encountered: