num-traits
num-traits copied to clipboard
Numeric traits for generic mathematics in Rust
In Rust 1.45, the `as` operator was changed to be a saturating cast for numeric types, but the num_traits library currently only seems to support checked casts (returning `Option`). Maybe...
I am currently working on converting `ndarray` to `no_std`, but this has resulted in one particular pain point: https://github.com/rust-ndarray/ndarray/issues/708#issuecomment-743914960. The underlying issue is that ndarray uses `Float` currently, but `Float`...
At the top of the [docs](https://docs.rs/num-traits/0.2.14/num_traits/real/trait.Real.html#tymethod.signum), it explicitly says that the `Real` trait is for things that might not have the concept of `NaN`. However, the docs for [`sqrt`](https://docs.rs/num-traits/0.2.14/num_traits/real/trait.Real.html#tymethod.sqrt), [`abs`](https://docs.rs/num-traits/0.2.14/num_traits/real/trait.Real.html#tymethod.abs),...
My Idea is something like this (I am not good with names, feel free to suggest better names): ```rust pub trait HasSignedVersion: Unsigned { type Signed: Signed; } impl HasSignedVersion...
"Numeric traits for generic mathematics in Rust." is a nice concise one-line description of num_traits. There's just one problem: I have no clue what the crate actually does! Provide traits...
In many iterative numerical algorithms, one has to calculate the distance between a solution candidate and a reference value in order to check for convergence. But currently there is no...
I recently found myself wanting "absolute value of the difference" for potentially-unsigned values, thought that `abs_sub` might be it, found that it wasn't implemented for `Unsigned`, and then found out...
The `float::FloatCore::max` and `float::FloatCore::min` doctests fail on mipsel and mips64el when building the Debian package of `num-traits`. I was able to reproduce the behavior on a mipsel vm with Debian...
As it says on the tin: `AsPrimitive` has not been implemented for `bool`. Is this intentional or an oversight? It's implemented for all `{integer}`, which makes it very difficult to...
While the `PrimInt` trait itself doesn't have compile time width functions, there are other ways to find the width of the underlying type. It is useful to present the alternative.