NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #4494 most downloaded on crates.io
Arbitrary-precision integers, rational, floating-point and complex numbers based on GMP, MPFR and MPC.
Last release 5 months ago
27 Apr 2026
Ships fairly regularly
a new release about every 2 months
Nearly every release is documented
notes for 55 of 58 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
58 releases · first in 2017
Arithmetic operators are now overloaded to work between:
Integer and MiniIntegerRational and MiniRationalFloat and MiniFloatComplex and MiniComplexMiniRational:
One column per quarter.
The [*az* crate] dependency was updated to [version 1.3][az-1-3].
Complex:
Bug fix: incorrect underflow when dividing [Rational][rat-1-28] by [Float][flo-1-28] ([issue 85]).
The crate now requires rustc version 1.85.0 or later.
Float:
Complex:
num-complex was added (issue
84).borsh was added (merge request
6).The [*az* crate], which is a dependency, is now re-exported ([issue 73]).
Bug fix: implementations of [CompleteRound][compr-1-26] were wrongly using [prec_t][sys-mpfr-p-1-6] instead of [u32] for [CompleteRound][compr-1-26]::
CompleteRound were wrongly using
prec_t instead of [u32] for
<code>CompleteRound::Prec</code> (issue 72).Bug fix: [Complete][c-1-26] was not implemented but documented for incomplete values produced by the following methods ([issue 69]):
Complete was not implemented but documented for
incomplete values produced by the following methods (issue 69):
* <code>Integer::clamp_ref</code>,
<code>Integer::invert_ref</code>,
<code>Integer::pow_mod_ref</code>
* <code>Integer::random_bits</code>,
<code>Integer::random_below_ref</code>
nightly-float was added (issue
68).Bug fix: implementations of [CompleteRound][compr-1-25] were wrongly using [prec_t][sys-mpfr-p-1-6] instead of [u32] for [CompleteRound][compr-1-25]::
CompleteRound were wrongly using
prec_t instead of [u32] for
<code>CompleteRound::Prec</code> (issue 72).The following functions were added:
Bug fix: a precondition for slice::from_raw_parts was being violated ([issue 63]).
slice::from_raw_parts was being violated
(issue 63).The implementation of the deprecated [SmallInteger][smi-1-24], [SmallRational][smr-1-24], [SmallFloat][smf-1-24] and [SmallComplex][smc-1-24] was chan…
Float now implements
<code>AssignRound<[bool][bool]></code>.
std optional feature was added (issue 62). The feature
is enabled by default, and the crate will be compiled without the standard
library (no_std) if the feature is disabled.MiniRational now implements
From]<MiniInteger></code>,
<code>Assign<MiniInteger></code>MiniFloat now implements
From]<[bool][bool]></code>,
<code>Assign<[bool][bool]></code>MiniComplex now implements
MiniInteger:
MiniRational:
MiniFloat:
MiniComplex:
num-traits experimental feature is enabled,
the following traits are implemented for Integer:
std now requires the std feature to be
enabled. While the std feature is enabled by default, it is now disabled
if the crate’s default features are disabled in [Cargo.toml]. In this
case, std must be added to the list of features to reenable the
functionality.SmallInteger,
SmallRational, SmallFloat and
SmallComplex was changed to remove [their soundness
issue][issue 52]. They now allocate memory for the digits, though their
whole point was to be non-allocating.…and [SmallComplex][smc-1-23], which are now deprecated.
MiniInteger, MiniRational, MiniFloat
and MiniComplex were added to replace
SmallInteger, SmallRational,
SmallFloat and SmallComplex, which are now
deprecated.
* The new structs do not implement [Deref] directly, as this causes
issues with the current Rust memory models (issue 52).
* Borrowing requires the use of the borrow methods, which
return an object that implements [Deref].
* The new borrow_excl methods were also added; they
require exclusive access in order to save on some housekeeping and to
return references directly without the need of [Deref].
* The new structs implement [Copy] and [Sync].For the [Complex][com-1-22] struct, the method [eq0][com-e-1-22] was renamed to [is_zero][com-iz-1-22]. The old method name is deprecated.
PartialOrd] and [PartialEq] between
Rational numbers and tuples of two primitive integers were
breaking the transitivity property of the traits, so the implementations
were removed (issue 58). See the compatibility note below.
PartialOrd] and [PartialEq] comparisons are now implemented
Integer and SmallInteger,Rational and SmallRational, andFloat and SmallFloat.PartialEq] comparisons are now implemented between
Complex and SmallComplex.SmallInteger can now be assigned or converted directly to
Integer using Assign and [From].SmallRational can now be assigned or converted directly to
Rational using Assign and [From].SmallFloat can now be assigned directly to Float
using AssignRound and Assign.SmallComplex can now be assigned directly to
Complex using AssignRound and
Assign.Debug] is now implemented for SmallInteger,
SmallRational, SmallFloat and
SmallComplex.Complex struct, the method eq0 was
renamed to is_zero. The old method name is deprecated.The implementations of [PartialOrd] and [PartialEq] between
Rational numbers and tuples of two primitive integers were
breaking the transitivity property of the two traits in question. Since the
implementations necessarily break the trait guarantees, having the traits
implemented is considered a bug (see issue 58 for more details). These buggy
implementations were removed. To fix code that used these comparisons without
adding extra allocations, SmallRational can be used. For example
rational == (1, 3) can be replaced with
rational == SmallRational::from((1, 3)).
The following methods were added to [Integer][int-1-21]:
Integer:
* is_zero, is_positive,
is_negative
* modulo, modulo_mut,
modulo_from, modulo_ref
Rational:
Rational zero (issue 53).Complete was implemented for incomplete values produced by
DivRounding and RemRounding implementations
(merge request 4).Bug fix: [Float][flo-1-20]::[to_f32_round][flo-tfr-1-20] was rounding some numbers in the subnormal range incorrectly ([issue 56]).
The [gmp-mpfr-sys] dependency was updated to [version 1.6][sys-1-6].
Bug fix: a zero denominator could be left after catching a panic from [Rational][rat-1-19]::[mutate\_numer\_denom][rat-mnd-1-19] ([issue 49]).
Bug fix: [Rational][rat-1-19]::[mutate\_numer\_denom][rat-mnd-1-19] and [Complex][com-1-19]::[mutate\_real\_imag][com-mri-1-19] were not unwind-safe (
The crate now requires rustc version 1.65.0 or later.
Float:
sin_u, sin_u_mut,
sin_u_round, sin_u_refcos_u, cos_u_mut,
cos_u_round, cos_u_reftan_u, tan_u_mut,
tan_u_round, tan_u_refsin_pi, sin_pi_mut,
sin_pi_round, sin_pi_refcos_pi, cos_pi_mut,
cos_pi_round, cos_pi_reftan_pi, tan_pi_mut,
tan_pi_round, tan_pi_refasin_u, asin_u_mut,
asin_u_round, asin_u_refacos_u, acos_u_mut,
acos_u_round, acos_u_refatan_u, atan_u_mut,
atan_u_round, atan_u_refatan2_u, atan2_u_mut,
atan2_u_round, atan2_u_refasin_pi, asin_pi_mut,
asin_pi_round, asin_pi_refacos_pi, acos_pi_mut,
acos_pi_round, acos_pi_refatan_pi, atan_pi_mut,
atan_pi_round, atan_pi_refatan2_pi, atan2_pi_mut,
atan2_pi_round, atan2_pi_reflog2_1p, log2_1p_mut,
log2_1p_round, log2_1p_reflog10_1p, log10_1p_mut,
log10_1p_round, log10_1p_refexp2_m1, exp2_m1_mut,
exp2_m1_round, exp2_m1_refexp10_m1, exp10_m1_mut,
exp10_m1_round, exp10_m1_refcompound_i, compound_i_mut,
compound_i_round, compound_i_refroot_i, root_i_mut,
root_i_round, root_i_refComplex:
BorrowInteger, BorrowRational,
BorrowFloat and BorrowComplex now implement
[Clone], [Copy] and formatting traits; and each have a static method
const_deref.…The old method names are deprecated.
Integer struct, the methods
gcd_cofactors, gcd_cofactors_mut and
gcd_cofactors_ref were renamed to
extended_gcd, extended_gcd_mut and
extended_gcd_ref. The old method names are deprecated.
Clone], [Copy], [PartialEq] and [Eq].IntegerExt64 extension trait was added to support very
large integers better on some 64-bit platforms.The new method [Integer][int-1-17]::[assign\_bytes\_radix\_unchecked][int-abru-1-17] was added ([issue 41]).
Integer now implements [LowerExp] and [UpperExp] for
convenience by transparently converting the Integer to a
Float (issue 42).CompleteRound trait is now implemented for
CompleteRound trait is now also implemented for
Now [Float][flo-1-16] implements [Cast][az-c-1-1], [CheckedCast][az-cc-1-1] and [UnwrappedCast][az-uc-1-1] with primitive integers as the destination
Float implements Cast,
CheckedCast and UnwrappedCast with primitive
integers as the destination types, in addition to the previously supported
SaturatingCast.
isize] and [usize].BorrowInteger, BorrowRational,
BorrowFloat and BorrowComplex structs were added.Now [Integer][int-1-15], [Rational][rat-1-15], [Float][flo-1-15] and [Complex][com-1-15] implement [Shl], [Shr], [ShlAssign] and [ShrAssign] with [isi
Integer, Rational, Float and
Complex implement [Shl], [Shr], [ShlAssign] and
[ShrAssign] with [isize] and [usize] as the type of the right-hand
side, in addition to the previously supported [i32] and [u32].
num-traits was added to
implement some traits from the [num-traits crate] and the [num-integer
crate] (issue 30).Bug fix: [Rational][rat-1-14]::[to_f32][rat-tf-1-14] was rounding away from zero in some cases when the rational number should be converted to a subno
Bug fix: [OrdFloat][ofl-1-14] was incorrectly ordering +NaN < −∞.
OrdFloat was incorrectly ordering +NaN < −∞.
Complete trait.CompleteRound trait was added to make it easier to
convert Float and Complex numbers
incomplete-computation values to their final value.The [incomplete-computation value][icv-1-13] returned by [Integer][int-1-13]::{[sum][int-s-1-13],[dot][int-d-1-13]} can now be subtracted from an [Int
Integer.
Rational number.Float.Complex number.Integer.Complete trait was added to make it easier to convert
incomplete-computation values to their final value.A new method [Integer][int-1-12]::[as\_limbs][int-al-1-12] was added.
The [gmp-mpfr-sys] dependency was updated to [version 1.4][sys-1-4].
Float numbers with only one
siginificant digit.The [gmp-mpfr-sys] dependency was updated to [version 1.3][sys-1-3].
Displaying [Float][flo-1-9] and [Complex][com-1-9] numbers, and converting them to strings, now avoids outputting an exponent term if the radix point
Float and Complex numbers, and
converting them to strings, now avoids outputting an exponent term if the
radix point can be moved to the correct place without inserting any extra
digits. For example "42.0" will be produced rather than "4.20e1" (issue
18). This change does not affect output when [LowerExp] ("{:e}" format)
or [UpperExp] ("{:E}" format) is used.
The output of Float and Complex numbers was changed as
specified above.
The following methods are now const functions:
SmallFloat and SmallComplex can now be initialized
with Special.SmallFloat and SmallComplex now implement
[Default].Integer now implements
<code>[AsRef][AsRef]<[[][slice]limb_t[]][slice]></code>.Float now implements
<code>[AsRef][AsRef]<OrdFloat></code>, and
OrdFloat now implements
<code>[AsRef][AsRef]<Float></code> and
<code>[AsMut][AsMut]<Float></code>.Complex now implements
<code>[AsRef][AsRef]<OrdComplex></code>, and
OrdComplex now implements
<code>[AsRef][AsRef]<Complex></code> and
<code>[AsMut][AsMut]<Complex></code>.The crate now requires rustc version 1.37.0 or later.
RemAssignRound and RemFromRound traits were
added.Rem], [RemAssign], RemFrom, RemAssignRound
and RemFromRound traits were implemented for
Float.Integer or integer primitive
operand and one Rational operand were added.SmallInteger, SmallRational,
SmallFloat and SmallComplex are no longer [Sync]
to avoid the possibility of a data race. References obtained by
dereferencing them, for example the <code>&Integer</code>
returned from <code>SmallInteger::[deref][deref]</code>, are
still [Send] and [Sync].Arithmetic operator implementations for [i8], [i16], [i64], [i128], [u8], [u16], [u64] and [u128] were added to the existing implementations for [i32]
i8], [i16], [i64],
[i128], [u8], [u16], [u64] and [u128] were added to the
existing implementations for [i32] and [u32].
FreeCache were added.ThreadRandState and a new trait
ThreadRandGen were added to the rand
module to enable the use of custom random generators that are not
[Send] and [Sync].RandState now can
also take ThreadRandState.Bug fix: [Pow][pow-1-5]<[i32][i32]> for [Rational][rat-1-5] was returning the reciprocal of the correct result.
i32]> for
[Rational][rat-1-5]</code> was returning the reciprocal of the correct
result.Bug fix: a memory leak in conversions of [Float][flo-1-5] to string was fixed (https://gitlab.com/tspiteri/rug/-/work_items/11).
Float][flo-1-5] to string was
fixed (https://gitlab.com/tspiteri/rug/-/work_items/11).A new method [Integer][int-1-5]::[assign\_digits\_unaligned][int-adu-1-5] was added to enable reading digits from unaligned memory.
from_raw methods now use
[MaybeUninit] instead of
<code>[mem][mem]::[uninitialized][uninitialized]</code>.The crate now requires rustc version 1.31.0 or later.
&self instead of &mut self.A new method [SmallRational][smr-1-3]::[assign\_canonical][smr-ac-1-3] was added.
Fixed bug in [Integer][int-1-2]::[assign\_digits][int-ad-1-2] . (Thanks: Eric Scrivner)
The [NotAssign][noa-1-2], [BitAndFrom][baf-1-2], [BitOrFrom][bof-1-2] and [BitXorFrom][bxf-1-2] traits were implemented for [bool].
NotAssign][noa-1-2], [BitAndFrom][baf-1-2], [BitOrFrom][bof-1-2]
and [BitXorFrom][bxf-1-2] traits were implemented for [bool].
NegAssign][nea-1-2] trait was implemented for [f32] and [f64].The [Integer][int-1-2] methods [from_digits][int-fd-1-2], [assign_digits][int-ad-1-2], [significant_digits][int-sd-1-2], [to_digits][int-td-1-2] and [
Integer][int-1-2] methods [from_digits][int-fd-1-2],
[assign_digits][int-ad-1-2], [significant_digits][int-sd-1-2],
[to_digits][int-td-1-2] and [write_digits][int-wd-1-2] now support
[bool] [slices][slice].The implementations of [Sum] and [Product] for [Integer][int-1-2] and [Rational][rat-1-2] were generalized to accept more types of elements.
Sum] and [Product] for Integer and
Rational were generalized to accept more types of elements.
Support for unstable [i128], [u128] and [TryFrom] was added in nightly.
i128], [u128] and [TryFrom] was added in
nightly.Support for [i128] and [u128] conversions and comparisons was added, conditional on compiler support.
i128] and [u128] conversions and comparisons was added,
conditional on compiler support.
TryFrom] conversions were implemented
for conversions
A bug in [Integer][int-1-0]::[reserve][int-r-1-0] , which was shrinking the capacity in some cases, was fixed.
A new method [Integer][int-1-0]::[is\_power\_of\_two][int-ipot-1-0] was added.
All deprecated items were removed.
Result]<(), ()></code> instead of [bool].
SmallRational and on <code>T where SmallFloat:
Assign<T></code> inside SmallComplex were
removed.Add Integer::parse and Rational::parse, and deprecate ValidInteger, ValidRational, valid_str_radix methods, and assign_str* methods.
Integer::invert_ref and Integer::pow_mod_ref now return an Option, not
an object that is assignable to Result.
Float::random_bits and Complex::random_bits are now assignable to the
number values, not to Result objects.Rational::signum, Rational::trunc, Rational::ceil, Rational::floor
and Rational::round now return Rational.Complex::abs, Complex::arg and Complex::norm now return Complex.Default implementations from all types of Float and Complex;
now the precision always has to be specified.Sum and Product implementations for Float and Complex.Clone and Copy implementations from all incomplete computation
types.Integer::parse and Rational::parse, and deprecate ValidInteger,
ValidRational, valid_str_radix methods, and assign_str* methods.Float::parse and Complex::parse, and deprecate ValidFloat,
ValidComplex, from_str* methods, valid_str_radix methods, and
assign_str* methods.Integer::gcd_coeffs* methods to Integer::gcd_cofactors*.Integer::gcd_cofactors_ref now supports computing only one cofactor.Rational::to_integer and Rational::as_numer_denom.Rational::as_mut_numer_denom and replace with
Rational::mutate_numer_denom.Complex::as_real_imag.Add Integer::square and Rational::square methods.
Integer::square and Rational::square methods.
Rational::cmp_abs method.Float::sum and Complex::sum methods.from_raw, into_raw, as_raw and as_raw_mut to RandState.RandGen::boxed_clone and RandState::new_custom_boxed, and thus
support for cloning custom random generators.Float::PartialOrd<f32> (and <f64>) to return None when the
primitive is NaN.Deprecate most assign_* methods, and replace with static methods that return an assignable object.
assign_* methods, and replace with static methods that
return an assignable object.Rational::copy_to_integer method.Rational::assign_canonical and Rational::from_canonical methods.Float::ln_u method.Float::round_even methods.Float::gamma_inc methods.Float::random_normal and Float::random_exp methods.Float::assign_random_gaussian methods.Complex::cmp_abs method.Complex::root_of_unity method.SmallRational::from_canonicalized_* methods and replace with
SmallRational::from_canonical method.SmallRational::assign_canonicalized_* methods.as_nonreallocating_* methods to SmallInteger, SmallRational,
SmallFloat and SmallComplex.SmallFloat::new and SmallComplex::new to produce numbers with a
precision of 53.float::Round::AwayFromZero.Integer::signum, Rational::signum and Float::signum methods.from_raw, into_raw, as_raw and as_raw_mut to Integer,
Rational, Float and Complex.Float::classify method.Float::mul_add, Float::mul_sub, Float::mul_add_mul and
Float::mul_sub_mul methods.Complex::mul_add and Complex::mul_sub methods.Implement mathematical operations where operands include references to primitives.
mem::swap(&mut src, &mut uninitialized) with ptr::copy_nonoverlapping(&src, &mut uninitialized, 1).Deprecate Rational::fract methods and replace with Rational::rem_trunc methods.
rug::float::AssignRound to rug::ops::AssignRound.
OrdFloat now orders +NaN above +∞, while −NaN is still below
−∞.Float::subnormalize methods to require explicit minimum normal
exponent.Float::subnormalize_ieee methods to deduce exponent range from
precision, like old Float::subnormalize. The new method also supports all
IEEE 754-2008 precisions corresponding to k storage bits where k ≥ 128 and k
is a multiple of 32.Rational::fract methods and replace with Rational::rem_trunc
methods.Rational::rem_ceil and Rational::rem_floor methods.Rational::rem_round and Rational::fract_round methods.Float::next_toward, Float::next_up and Float::next_down.Rename Integer::sign, Rational::sign and Float::sign methods as Integer::cmp0, Rational::cmp0 and Float::cmp0.
Integer::sign, Rational::sign and Float::sign methods as
Integer::cmp0, Rational::cmp0 and Float::cmp0.
Float::pos_diff as Float::positive_diff.rug::AssignRound to rug::float::AssignRound.Integer::clamp, Rational::clamp and Float::clamp methods.Integer::div_rem_ceil, Integer::div_rem_floor and
Integer::div_rem_euc methods.DivRounding, DivRoundingAssign and DivRoundingFrom traits, and
their Rem counterparts, and implement them for Integer, and for
combinations of Integer with i32 or u32.Rational::fract_floor and Rational::fract_ceil methods.Fix swapped Float::sin_cos_mut and Float::sin_cos_round, Float::sinh_cosh_mut and Float::sinh_cosh_round, and Float::trunc_fract_mut and Float::trunc_
Float::sin_cos_mut and Float::sin_cos_round,
Float::sinh_cosh_mut and Float::sinh_cosh_round, and
Float::trunc_fract_mut and Float::trunc_fract_round.
Float::to_f32_round.Float::subnormalize only works for precisions defined in IEEE 754.Integer::gcd_coeffs methods.Rename Float::abs_diff as Float::pos_diff.
Float::abs_diff as Float::pos_diff.Float::get_sign with Float::is_sign_positive and
Float::is_sign_negative.as_neg, as_abs and as_conj methods.OrdFloat and OrdComplex for complete ordering.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 →