Crate newnum Copy item path Source derive Derive macros for crate traits. num Converts a numeric literal into a Num
type, generating a compile-time error if the literal is out of range for the type. num_approx Converts a numeric literal into a Num
type, generating a compile-time error if the literal is out of range for the type.
In comparison to num!
, this macro also accepts literals that can only be approximately represented by the type. AHyper ATrig Inverse trigonometric API (asin
, acos
, atan
).
Functions take in self
and return Output
. AbsDiff Trait for abs_diff
method, which computes the absolute difference between two numbers.
abs_diff
is equivalent to (a - b).abs()
, not a.abs() - b.abs()
. AlwaysNegative Trait for types that are always negative (number / number-container). AlwaysPositive Trait for types that are always positive (number / number-container). AlwaysZero Trait for types that are always zero (number / number-container). AsPrim Bounded Trait for types with both minimum and maximum values. Float Floating FloatingEquivalent FromFloatLiteral Used by the num
macro to convert float literals to Self
. FromIntLiteral Used by the [num
] macro to convert integer literals to Self
. FullySigned Trait for types that can represent both positive values, negative values and zero (number / number-container). Hyper Int MinMax trait for min
, max
fns. Negative Trait for types that can represent negative values (number / number-container). NegativeOrZero Trait for types that are always either negative or zero (number / number-container). NoTypeMax For types without a maximum value. NoTypeMin For types without a minimum value. NotNegative Trait for types that are never negative (number / number-container). NotPositive Trait for types that are never positive (number / number-container). NotZero Trait for types that are never zero (number / number-container). Num Trait for types that represent numbers. Positive Trait for types that can represent positive values (number / number-container). PositiveOrNegative Trait for types that are always either positive or negative, so never zero (number / number-container). PositiveOrZero Trait for types that are always either positive or zero (number / number-container). Prim Trait for number primitives (u8
, i32
, f64
…). Root Trait for sqrt
and cbrt
methods, which compute the square root and cube root of a number. Round Trait for the round API (round
, floor
…)
which may be used for numbers, number containers, or anything that makes sense. SInt Sign Trait for types that have a mathamatical sign (number / number-container). SignedPrim Signum Trait for signum
functions. Trig Trigonometric API (sin
, cos
, tan
).
Functions take in self
and return Output
. TruncRoot Trait for trunc_sqrt
and trunc_cbrt
methods, which compute the truncated square root and cube root of a number. TypeMax For types with a maximum value. TypeMin For types with a minimum value. UInt Unbounded Trait for types with no minimum AND no maximum value. UnsignedPrim Whole Trait for numbers or number containers that are always round (for example i32
). WholeEquivalent Trait for numbers/number-containers that have whole/integer equivilants.
The Whole
type should be the lightest whole type that can represent the entire range of Self
. Zero Trait for types that can represent zero (number / number-container).