NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #55 most downloaded on crates.io
Numeric traits for generic mathematics
Last release 2 years ago
no release in 18 months
Release timing varies
gaps range from 9 days to 1.5 years
Most releases are documented
notes for 22 of 31 stable releases
1 version withdrawn
withdrawn after publishing
10 years old
32 releases · first in 2016
chore: Release num-traits version 0.2.19
chore: Release num-traits version 0.2.19
chore: Release num-traits version 0.2.18
One column per quarter.
Euclid::div_rem_euclid and CheckedEuclid::checked_div_rem_euclid methods
compute and return the quotient and remainder at the same time.TotalOrder trait implements the IEEE 754 totalOrder predicate.ConstZero and ConstOne traits offered associated constants,
extending the non-const Zero and One traits for types that have constant values.Contributors: @andrewjradcliffe, @cuviper, @tarcieri, @tdelabro, @waywardmonkeys
[Fix a doc warning about custom classes with newer rustdoc.][286]
Contributors: @robamu
[Upgrade to 2018 edition, MSRV 1.31][240]
ToBytes and FromBytes traits convert to and from byte
representations of a value, with little, big, and native-endian options.Float::is_subnormal method checks for subnormal values, with
a non-zero magnitude that is less than the normal minimum positive value.Contributors: @ctrlcctrlv, @cuviper, @flier, @GuillaumeGomez, @kaidokert, @rs017991, @vicsn
[The new Euclid trait calculates Euclidean division][195], where the remainder is always positive or zero.
Euclid trait calculates Euclidean division, where the
remainder is always positive or zero.LowerBounded and UpperBounded traits separately describe
types with lower and upper bounds. These traits are automatically implemented
for all fully-Bounded types.Float::copysign method copies the sign of the argument to
to the magnitude of self.PrimInt::leading_ones and trailing_ones methods are the
complement of the existing methods that count zero bits.PrimInt::reverse_bits method reverses the order of all bits
of a primitive integer.Num::from_str_radix for floats, also ignoring case.Float and FloatCore use more from libm when that is enabled.Contributors: @alion02, @clarfonthey, @cuviper, @ElectronicRU, @ibraheemdev, @SparrowLii, @sshilovsky, @tspiteri, @XAMPPRocky, @Xiretza
Clarify the license specification as "MIT OR Apache-2.0".
Contributors: @cuviper
[The new OverflowingAdd, OverflowingSub, and OverflowingMul traits][180] return a tuple with the operation result and a bool indicating overflow.
OverflowingAdd, OverflowingSub, and OverflowingMul traits
return a tuple with the operation result and a bool indicating overflow.autocfg probing doesn't work properly.f64 values to f32 now saturate to infinity. They
previously returned None because that was once thought to be undefined
behavior, but rust#15536 resolved that such casts are fine.Num::from_str_radix documents requirements for radix support, which
are now more relaxed than previously implied. It is suggested to accept at
least 2..=36 without panicking, but Err may be returned otherwise.Contributors: @cuviper, @Enet4, @KaczuH, @martin-t, @newpavlov
…if the operation would overflow. These soft-deprecate the existing Saturating trait that only has addition and subtraction methods.
WrappingNeg trait will wrap the result if it exceeds the
boundary of the type, e.g. i32::MIN.wrapping_neg() == i32::MIN.SaturatingAdd, SaturatingSub, and SaturatingMul traits
will saturate at the numeric bounds if the operation would overflow. These
soft-deprecate the existing Saturating trait that only has addition and
subtraction methods.FloatConst::{LOG10_2, LOG2_10}.Contributors: @cuviper, @ocstl, @trepetti, @vallentin
[Added the full circle constant τ as FloatConst::TAU][145].
Contributors: @cuviper, @m-ou-se
[Updated the libm dependency to 0.2][144].
Contributors: @CryZe
[A new optional libm dependency][99] enables the Float and Real traits in no_std builds.
libm dependency enables the Float and Real traits
in no_std builds.clamp_min and clamp_max limit minimum and maximum values
while preserving input NANs.from_str_radix on invalid signs.Contributors: @cuviper, @dingelish, @HeroicKatora, @jturner314, @ocstl, @Shnatsel, @termoshtt, @waywardmonkeys, @yoanlcq
[Fixed feature detection on no_std targets][116].
Contributors: @cuviper
[Documented when CheckedShl and CheckedShr return None][90].
CheckedShl and CheckedShr return None.Zero::set_zero and One::set_one will set values to their
identities in place, possibly optimized better than direct assignment.PrimInt.Contributors: @cuviper, @dvdhrm, @ignatenkobrain, @lcnr, @samueltardieu
[Documented that pow(0, 0) returns 1][79]. Mathematically, this is not strictly defined, but the current behavior is a pragmatic choice that has prece
pow(0, 0) returns 1. Mathematically, this is not
strictly defined, but the current behavior is a pragmatic choice that has
precedent in Rust core for the primitives and in many other languages.WrappingShl and WrappingShr traits will wrap the shift count
if it exceeds the bit size of the type.Contributors: @cuviper, @edmccard, @meltinglava
[Documentation for mul_add now clarifies that it's not always faster.][70]
[Support for 128-bit integers is now automatically detected and enabled.][69] Setting the i128 crate feature now causes the build script to panic if s
i128 crate feature now causes the build script to panic if such
support is not detected.Contributors: @cuviper
[The new CheckedNeg and CheckedRem traits][63] perform checked Neg and Rem, returning Some(output) or None on overflow.
CheckedNeg and CheckedRem traits perform checked Neg and
Rem, returning Some(output) or None on overflow.no_std implementation of FloatCore::to_degrees for f32 now
uses a constant for greater accuracy, mirroring rust#47919. (With std it
just calls the inherent f32::to_degrees in the standard library.)MulAdd and MulAddAssign traits perform a fused multiply-
add. For integer types this is just a convenience, but for floating point
types this produces a more accurate result than the separate operations.i128 crate feature. The FromPrimitive
and ToPrimitive traits now also have corresponding 128-bit methods, which
default to converting via 64-bit integers for compatibility.Contributors: @cuviper, @LEXUGE, @regexident, @vks
[Casting from floating point to integers now returns None on overflow][52], avoiding [rustc's undefined behavior][rust-10184]. This applies to the cas
None on overflow,
avoiding rustc's undefined behavior. This applies to the cast
function and the traits NumCast, FromPrimitive, and ToPrimitive.Contributors: @apopiak, @cuviper, @dbarella
[The new FloatCore trait][32] offers a subset of Float for #![no_std] use. [This includes everything][41] except the transcendental functions and FMA.
FloatCore trait offers a subset of Float for #![no_std] use.
This includes everything except the transcendental functions and FMA.Inv trait returns the multiplicative inverse, or reciprocal.Pow trait performs exponentiation, much like the existing pow
function, but with generic exponent types.One::is_one method tests if a value equals 1. Implementers
should override this method if there's a more efficient way to check for 1,
rather than comparing with a temporary one().Contributors: @clarcharr, @cuviper, @vks
breaking change: [There is now a std feature][30], enabled by default, along with the implication that building *without* this feature makes this a #!…
std feature, enabled by default, along
with the implication that building without this feature makes this a
#![no_std] crate.
Float and Real traits are only available when std is enabled.Contributors: @cuviper, @termoshtt, @vks
All items are now [re-exported from num-traits 0.2][31] for compatibility.
[num-traits now has its own source repository][num-356] at [rust-num/num-traits][home].
ParseFloatError now implements Display.AsPrimitive trait implements generic casting with the as operator.CheckedShl and CheckedShr traits implement generic
support for the checked_shl and checked_shr methods on primitive integers.Real trait offers a subset of Float functionality that may be applicable to more
types, with a blanket implementation for all existing T: Float types.Thanks to @cuviper, @Enet4, @fabianschuiki, @svartalf, and @yoanlcq for their contributions!
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →