Crate numeric_float [−] [src]
This crate defines variants of the f32
and f64
types which exclude Not-a-Number. These types are collectively called "numeric". As a consequence of never being NaN
, these types implement Eq
, Ord
, and Hash
.
They also attempt to define all relevant operations one would expect to be able to perform on floating-point numbers. The problem is what to do about operations that might result in NaN
.
The n*f
types handle operations that result in NaN
by instead returning the underlying f*
result directly. For example, adding two n32f
s results in an f32
.
The n*p
types handle operations that result in NaN
by panicking when NaN
is produced. Some operations which panic also have try_*
alternatives that return Option<Self>
instead.
Supported Traits
Where possible, the types in this crate implement all traits which are implemented on the corresponding f*
type. In addition to those in the standard library, the following crates are also optionally supported:
The following are explicitly not supported:
DecodableFloat
, andRawFloat
are internal and not stable to implement.One
,Zero
, and*Assign
are unstable.ieee754
: theIeee754
trait cannot be implemented for new types.num
:Float
,Num
,One
,Signed
, andZero
cannot be implemented forn*f
.
Structs
n32f |
A 32-bit floating point type which excludes Not-a-Number. |
n32p |
A 32-bit floating point type which excludes Not-a-Number. |
n64f |
A 64-bit floating point type which excludes Not-a-Number. |
n64p |
A 64-bit floating point type which excludes Not-a-Number. |
Enums
ParseNumericError |
An error which can be returned when parsing a numeric float (e.g. |
Traits
Numeric |
This trait is implemented for all numeric float types in this crate. |