- Bug fix:
rem_euclid_intand its checked versions were handling overflow incorrectly.
- Bug fix:
round_to_zerowas returning incorrect results for negative whole number operands. - Bug fix: all remainder operations with a fixed-point LHS and an integer RHS were giving an incorrect answer (https://gitlab.com/tspiteri/fixed/issues/13).
- Bug fix: Euclidean division operations by integers were giving an incorrect answer.
RemandRemAssignwere implemented for fixed-point numbers.- The following methods were added to all fixed-point types and to
the
Fixedtrait:checked_remdiv_euclid,rem_euclidchecked_div_euclid,checked_rem_euclidsaturating_div_euclidwrapping_div_euclidoverflowing_div_euclid
- The following methods were added to the
Wrappingwrapper:div_euclid,rem_eucliddiv_euclid_int,rem_euclid_int
- The following methods were deprecated:
wrapping_rem_int,overflowing_rem_int
Wrappingnow supports serialization. (Thanks: Shane Pearman)
ParseFixedErrorimplementsErrorwhen the newstdfeature is enabled.
- The fixed crate now requires rustc version 1.39.0 or later.
- The following methods were added to all fixed-point types and to
the
Fixedtrait:from_be_bytes,from_le_bytes,from_ne_bytesto_be_bytes,to_le_bytes,to_ne_bytesdiv_euclid_int,rem_euclid_intchecked_div_euclid_int,checked_rem_euclid_intwrapping_div_euclid_int,wrapping_rem_euclid_intoverflowing_div_euclid_int,overflowing_rem_euclid_int
- Deprecated methods and modules were removed.
- Conversions to/from
bf16are now provided when thef16option is enabled. - The following methods are now
constfunctions:saturating_neg,saturating_add,saturating_sub,saturating_mul_int,saturating_abs - Support for casts using the az crate was added.
- Bug fix: display of many decimal numbers was panicking in debug mode or including a leading zero in release mode.
- Many methods were added to
Wrappingfor convenience, even if they do not involve wrapping.
- Bug fix: rounding could produce bad output for
Binary,Octal,LowerHexandUpperHex. - The following methods are now
constfunctions:is_power_of_two,abs,wrapping_abs,overflowing_abs - The method
round_to_zerowas added. - The method
round_ties_to_evenand its checked versions were added.
- The fixed crate now requires rustc version 1.34.0 or later.
- The precision argument is no longer ignored when formatting fixed-point numbers; precision should now be handled the same as for primitive floating-point numbers in the standard library.
- Parsing strings now rounds to the nearest with ties rounded to even.
- Checked versions of string parsing methods are now available as
inherent methods to all fixed-point numbers, and as methods in the
Fixedtrait. Wrappingnow has methods for parsing with wrapping, including an implementation ofFromStr.- The following methods are now
constfunctions:min_value,max_value,from_bits,to_bitscount_ones,count_zeros,leading_zeros,trailing_zerosrotate_left,rotate_rightwrapping_neg,wrapping_add,wrapping_sub,wrapping_mul_int,wrapping_shl,wrapping_shroverflowing_neg,overflowing_add,overflowing_sub,overflowing_mul_int,overflowing_shl,overflowing_shris_positive,is_negative
- The associated constants
INT_NBITSandFRAC_NBITSwere added. - The reexports in the
fracmodule and theLeEqU*traits were moved into the newtypes::extramodule.
- The new methods
from_numandto_numtogether with their checked versions were added to all fixed-point numbers. - The methods
from_fixed,to_fixed,from_int,to_int,from_float, andto_float, and their checked versions, were deprecated. - The new method
from_numwas added to theWrappingwrapper. - Bug fix: parsing of decimal fractions was fixed to give correctly rounded results for long decimal fraction strings, for example with four fractional bits, 0.96874999… (just below 31⁄32) and 0.96875 (31⁄32) are now parsed correctly as 0.9375 (15⁄16) and 1.0.
- All fixed-point types now implement
FromStr. - The methods
from_str_binary,from_str_octalandfrom_str_hexwere added.
- The fixed crate now requires rustc version 1.31.0 or later.
- The
traitsmodule was added, with its traitsFixed,FixedSigned,FixedUnsigned,FromFixed,ToFixed,LossyFromandLossyInto. - The
saturating_negmethod was added to all fixed-point numbers, and thesaturating_absmethod was added to signed fixed-point numbers. - The
constsmodule was added. - The
signummethod now wraps instead of panics in release mode.
- The sealed traits
IntandFloatnow have no provided methods; the methods in the old implementation are now provided byFromFixedandToFixed. - Deprecated methods were removed.
- @jean-airoldie
- @tspiteri
- Conversions to/from
isizeandusizewere added.
- The
Wrappingwrapper was added.
- Reimplement
From<bool>for all fixed-point types which can represent the integer 1. This was inadvertently removed in 0.3.0.
- Incompatible change: the return type of
to_intis now generic. - Incompatible change: the
Inttrait implementation forboolwas removed. - The new method
to_fixedwas added. - The new methods
checked_to_fixed,checked_to_int,saturating_to_fixed,saturating_to_int,wrapping_to_fixed,wrapping_to_int,overflowing_to_fixedandoverflowing_to_intwere added. - The methods
from_fixed,to_fixed,checked_from_fixed,checked_to_fixed,saturating_from_fixed,saturating_to_fixed,wrapping_from_fixed,wrapping_to_fixed,overflowing_from_fixedandoverflowing_to_fixedwere added to theInttrait. - The methods
from_fixed,to_fixed,checked_to_fixed,saturating_to_fixed,wrapping_to_fixedandoverflowing_to_fixedwere added to theFloattrait. PartialEqandPartialCmpare now implemented for all combinations of fixed-point numbers and primitive integers.- The methods
int_bitsandfrac_bitswere deprecated and replaced by the methodsint_nbitsandfrac_nbits.
- Bug fix: the
from_fixedandfrom_intmethods (and their checked counterparts) could return wrong values for negative values. - Bug fix: display was using one fractional digit less than required, thus yielding the same output for diffent fixed-point numbers.
- Incompatible change: The method
from_intwas change to accept a generic parameter. - The new methods
from_fixed,checked_from_fixed,saturating_from_fixed,wrapping_from_fixedandoverflowing_from_fixedwere added. - The new methods
checked_from_int,saturating_from_int,wrapping_from_intandoverflowing_from_intwere added. - The new methods
from_float,checked_from_float,saturating_from_float,wrapping_from_floatandoverflowing_from_floatwere added. - The new method
to_floatwas added. - The methods
from_f16,from_f32,from_f64,to_f16,to_f32andto_f64were deprecated. - The
to_intmethod was fixed to truncate fractional bits as documented for negative values. - The new methods
ceil,floor,round,checked_ceil,checked_floor,checked_round,saturating_ceil,saturating_floor,saturating_round,wrapping_ceil,wrapping_floor,wrapping_round,overflowing_ceil,overflowing_floorandoverflowing_roundwere added. - The methods
to_int_ceil,to_int_floorandto_int_roundwere deprecated.
- Optional serde support was added.
- Lossless infallible conversions between fixed-point numbers and
numeric primitives are now supported using
FromandInto. - A new module
typesis available with aliases for all supported fixed-point numbers.
- Division is now implemented for
FixedI128andFixedU128.
- The
f16feature was added, and new methodsfrom_f16andto_f16were added.
- The crate can now be used without the standard library
std. - New methods
from_f32andfrom_f64were added. - New methods
is_positiveandis_negativewere added to signed fixed-point numbers.
- Comparisons are now supported between all fixed-point numbers with the same underlying integer type.
- New static methods
int_bitsandfrac_bitswere added. - New methods
from_int,to_int,to_int_ceil,to_int_floorandto_int_roundwere added. - New methods
intandfracwere added. - Support for multiplication and division by integers was added.
Unsignedconstants provided by the typenum crate are now used for the number of fractional bits.- Many methods and trait implementations available for primitive integers are now also supported by the fixed-point numbers.