diff --git a/src/lib.rs b/src/lib.rs index f6349f0..a269480 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -502,7 +502,7 @@ assert_eq!(two_point_75.to_string(), \"2.8\"); // inherent methods that do not require Frac bounds, some of which can thus be const fixed_no_frac! { - $Fixed[$s_fixed]($Inner[$s_inner], $LeEqU, $s_nbits), + $Fixed[$s_fixed]($Inner[$s_inner], $LeEqU, $s_nbits, $s_nbits_m1), $nbytes, $bytes_val, $rev_bytes_val, $be_bytes, $le_bytes, $UFixed[$s_ufixed], $UInner, $Signedness, $Double, $DoubleInner, $s_nbits_2, $HasDouble diff --git a/src/macros_no_frac.rs b/src/macros_no_frac.rs index 935cf80..90d52b0 100644 --- a/src/macros_no_frac.rs +++ b/src/macros_no_frac.rs @@ -15,7 +15,9 @@ macro_rules! fixed_no_frac { ( - $Fixed:ident[$s_fixed:expr]($Inner:ty[$s_inner:expr], $LeEqU:tt, $s_nbits:expr), + $Fixed:ident[$s_fixed:expr]( + $Inner:ty[$s_inner:expr], $LeEqU:tt, $s_nbits:expr, $s_nbits_m1:expr + ), $nbytes:expr, $bytes_val:expr, $rev_bytes_val:expr, $be_bytes:expr, $le_bytes:expr, $UFixed:ident[$s_ufixed:expr], $UInner:ty, $Signedness:tt, $Double:ident, $DoubleInner:ty, $s_nbits_2:expr, $HasDouble:tt @@ -40,6 +42,9 @@ assert_eq!(Fix::ZERO, Fix::from_bits(0)); comment! { "The difference between any two successive representable numbers, Δ. +If the number has f = `Frac` fractional bits, then +Δ = 1/2f. + # Examples ```rust @@ -56,6 +61,17 @@ assert_eq!(Fix::DELTA, 0.0625); comment! { "The smallest value that can be represented. +", + if_signed_unsigned! { + $Signedness, + concat!( + "If the number has f = `Frac` fractional bits, +then the minimum is −2", $s_nbits_m1, "/2f." + ), + "The minimum of unsigned numbers is 0." + }, + " + # Examples ```rust @@ -70,6 +86,11 @@ assert_eq!(Fix::MIN, Fix::from_bits(", $s_inner, "::MIN)); comment! { "The largest value that can be represented. +If the number has f = `Frac` fractional bits, then the maximum is +(2", + if_signed_unsigned!($Signedness, $s_nbits_m1, $s_nbits), + " − 1)/2f. + # Examples ```rust