num-traits
Numeric traits for generic mathematics
0.2.19
944M downloads/mo
#54 most downloaded on crates.io
rust-num/num-traits
What this package is like to depend on
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
0 releases in the last 12 months
see the full history below
Release timeline
32 releases · Apr 2016 to May 2024Releases
latest 32-
0.2.1903 May 2024 -
0.2.1808 Feb 2024Release notes
Open source →- The new
Euclid::div_rem_euclidandCheckedEuclid::checked_div_rem_euclidmethods compute and return the quotient and remainder at the same time. - The new
TotalOrdertrait implements the IEEE 754totalOrderpredicate. - The new
ConstZeroandConstOnetraits offered associated constants, extending the non-constZeroandOnetraits for types that have constant values.
Contributors: @andrewjradcliffe, @cuviper, @tarcieri, @tdelabro, @waywardmonkeys
- The new
-
0.2.1707 Oct 2023 -
0.2.1620 Jul 2023Release notes
Open source →- Upgrade to 2018 edition, MSRV 1.31
- The new
ToBytesandFromBytestraits convert to and from byte representations of a value, with little, big, and native-endian options. - The new
Float::is_subnormalmethod checks for subnormal values, with a non-zero magnitude that is less than the normal minimum positive value. - Several other improvements to documentation and testing.
Contributors: @ctrlcctrlv, @cuviper, @flier, @GuillaumeGomez, @kaidokert, @rs017991, @vicsn
-
0.2.1503 May 2022Release notes
Open source →- The new
Euclidtrait calculates Euclidean division, where the remainder is always positive or zero. - The new
LowerBoundedandUpperBoundedtraits separately describe types with lower and upper bounds. These traits are automatically implemented for all fully-Boundedtypes. - The new
Float::copysignmethod copies the sign of the argument to to the magnitude ofself. - The new
PrimInt::leading_onesandtrailing_onesmethods are the complement of the existing methods that count zero bits. - The new
PrimInt::reverse_bitsmethod reverses the order of all bits of a primitive integer. - Improved
Num::from_str_radixfor floats, also ignoring case. FloatandFloatCoreuse more fromlibmwhen that is enabled.
Contributors: @alion02, @clarfonthey, @cuviper, @ElectronicRU, @ibraheemdev, @SparrowLii, @sshilovsky, @tspiteri, @XAMPPRocky, @Xiretza
- The new
-
0.2.1429 Oct 2020Release notes
Open source →- Clarify the license specification as "MIT OR Apache-2.0".
Contributors: @cuviper
-
0.2.1329 Oct 2020Release notes
Open source →- The new
OverflowingAdd,OverflowingSub, andOverflowingMultraits return a tuple with the operation result and aboolindicating overflow. - The "i128" feature now overrides compiler probes for that support.
This may fix scenarios where
autocfgprobing doesn't work properly. - Casts from large
f64values tof32now saturate to infinity. They previously returnedNonebecause that was once thought to be undefined behavior, but rust#15536 resolved that such casts are fine. Num::from_str_radixdocuments requirements for radix support, which are now more relaxed than previously implied. It is suggested to accept at least2..=36without panicking, butErrmay be returned otherwise.
Contributors: @cuviper, @Enet4, @KaczuH, @martin-t, @newpavlov
- The new
-
0.2.1211 Jun 2020Release notes
Open source →- The new
WrappingNegtrait will wrap the result if it exceeds the boundary of the type, e.g.i32::MIN.wrapping_neg() == i32::MIN. - The new
SaturatingAdd,SaturatingSub, andSaturatingMultraits will saturate at the numeric bounds if the operation would overflow. These soft-deprecate the existingSaturatingtrait that only has addition and subtraction methods. - Added new constants for logarithms,
FloatConst::{LOG10_2, LOG2_10}.
Contributors: @cuviper, @ocstl, @trepetti, @vallentin
- The new
-
0.2.1110 Jan 2020 -
0.2.1022 Nov 2019 -
0.2.913 Nov 2019Release notes
Open source →- A new optional
libmdependency enables theFloatandRealtraits inno_stdbuilds. - The new
clamp_minandclamp_maxlimit minimum and maximum values while preserving inputNANs. - Fixed a panic in floating point
from_str_radixon invalid signs. - Miscellaneous documentation updates.
Contributors: @cuviper, @dingelish, @HeroicKatora, @jturner314, @ocstl, @Shnatsel, @termoshtt, @waywardmonkeys, @yoanlcq
- A new optional
-
0.2.822 May 2019 -
0.2.720 May 2019Release notes
Open source →- Documented when
CheckedShlandCheckedShrreturnNone. - The new
Zero::set_zeroandOne::set_onewill set values to their identities in place, possibly optimized better than direct assignment. - Documented general features and intentions of
PrimInt.
Contributors: @cuviper, @dvdhrm, @ignatenkobrain, @lcnr, @samueltardieu
- Documented when
-
0.2.614 Sep 2018Release notes
Open source →- Documented that
pow(0, 0)returns1. Mathematically, this is not strictly defined, but the current behavior is a pragmatic choice that has precedent in Rustcorefor the primitives and in many other languages. - The new
WrappingShlandWrappingShrtraits will wrap the shift count if it exceeds the bit size of the type.
Contributors: @cuviper, @edmccard, @meltinglava
- Documented that
-
0.2.520 Jun 2018Release notes
Open source →- Documentation for
mul_addnow clarifies that it's not always faster. - The default methods in
FromPrimitiveandToPrimitiveare more robust.
Contributors: @cuviper, @frewsxcv
- Documentation for
-
0.2.411 May 2018Release notes
Open source →- Support for 128-bit integers is now automatically detected and enabled.
Setting the
i128crate feature now causes the build script to panic if such support is not detected.
Contributors: @cuviper
- Support for 128-bit integers is now automatically detected and enabled.
Setting the
-
0.2.310 May 2018Release notes
Open source →- The new
CheckedNegandCheckedRemtraits perform checkedNegandRem, returningSome(output)orNoneon overflow. - The
no_stdimplementation ofFloatCore::to_degreesforf32now uses a constant for greater accuracy, mirroring rust#47919. (Withstdit just calls the inherentf32::to_degreesin the standard library.) - The new
MulAddandMulAddAssigntraits 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. - All applicable traits are now implemented for 128-bit integers starting
with Rust 1.26, enabled by the new
i128crate feature. TheFromPrimitiveandToPrimitivetraits now also have corresponding 128-bit methods, which default to converting via 64-bit integers for compatibility.
Contributors: @cuviper, @LEXUGE, @regexident, @vks
- The new
-
0.2.218 Mar 2018Release notes
Open source →- Casting from floating point to integers now returns
Noneon overflow, avoiding rustc's undefined behavior. This applies to thecastfunction and the traitsNumCast,FromPrimitive, andToPrimitive.
Contributors: @apopiak, @cuviper, @dbarella
- Casting from floating point to integers now returns
-
0.2.101 Mar 2018Release notes
Open source →- The new
FloatCoretrait offers a subset ofFloatfor#![no_std]use. This includes everything except the transcendental functions and FMA. - The new
Invtrait returns the multiplicative inverse, or reciprocal. - The new
Powtrait performs exponentiation, much like the existingpowfunction, but with generic exponent types. - The new
One::is_onemethod 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 temporaryone().
Contributors: @clarcharr, @cuviper, @vks
- The new
-
0.2.007 Feb 2018Release notes
Open source →- breaking change: There is now a
stdfeature, enabled by default, along with the implication that building without this feature makes this a#![no_std]crate.- The
FloatandRealtraits are only available whenstdis enabled. - Otherwise, the API is unchanged, and num-traits 0.1.43 now re-exports its items from num-traits 0.2 for compatibility (the semver-trick).
- The
Contributors: @cuviper, @termoshtt, @vks
- breaking change: There is now a
-
0.1.4307 Feb 2018 -
0.1.4223 Jan 2018Release notes
Open source →- num-traits now has its own source repository at rust-num/num-traits.
ParseFloatErrornow implementsDisplay.- The new
AsPrimitivetrait implements generic casting with theasoperator. - The new
CheckedShlandCheckedShrtraits implement generic support for thechecked_shlandchecked_shrmethods on primitive integers. - The new
Realtrait offers a subset ofFloatfunctionality that may be applicable to more types, with a blanket implementation for all existingT: Floattypes.
Thanks to @cuviper, @Enet4, @fabianschuiki, @svartalf, and @yoanlcq for their contributions!
-
0.1.4101 Dec 2017Nothing published for this version
-
0.1.4015 Jul 2017Nothing published for this version
-
0.1.3909 Jun 2017Nothing published for this version
-
0.1.3809 Jun 2017 withdrawnNothing published for this version
-
0.1.3726 Feb 2017Nothing published for this version
-
0.1.3630 Sep 2016Nothing published for this version
-
0.1.3518 Aug 2016Nothing published for this version
-
0.1.3424 Jul 2016Nothing published for this version
-
0.1.3312 Jul 2016Nothing published for this version
-
0.1.3214 Apr 2016Nothing published for this version