Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ exclude = [
[features]
default = ["std"]
std = []

[dependencies]
cfg-if = "1.0.0"

[build-dependencies]
# NOTE: Due to some semver upgrading to a higher MSRV than our project
# supports, after any dependency updates, make sure to use:
# cargo update -Z minimal-versions
rustc_version = "0.4"

[package.metadata.docs.rs]
Expand Down
18 changes: 8 additions & 10 deletions src/bfloat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,9 +1500,9 @@ mod test {
let zero = bf16::from_f32(0.0);
let neg_zero = bf16::from_f32(-0.0);
let neg_one = bf16::from_f32(-1.0);
let inf = bf16::from_f32(core::f32::INFINITY);
let neg_inf = bf16::from_f32(core::f32::NEG_INFINITY);
let nan = bf16::from_f32(core::f32::NAN);
let inf = bf16::from_f32(f32::INFINITY);
let neg_inf = bf16::from_f32(f32::NEG_INFINITY);
let nan = bf16::from_f32(f32::NAN);

assert_eq!(bf16::ONE, one);
assert_eq!(bf16::ZERO, zero);
Expand Down Expand Up @@ -1530,11 +1530,9 @@ mod test {
let ln_10 = bf16::from_f32(core::f32::consts::LN_10);
let ln_2 = bf16::from_f32(core::f32::consts::LN_2);
let log10_e = bf16::from_f32(core::f32::consts::LOG10_E);
// core::f32::consts::LOG10_2 requires rustc 1.43.0
let log10_2 = bf16::from_f32(2f32.log10());
let log10_2 = bf16::from_f32(core::f32::consts::LOG10_2);
let log2_e = bf16::from_f32(core::f32::consts::LOG2_E);
// core::f32::consts::LOG2_10 requires rustc 1.43.0
let log2_10 = bf16::from_f32(10f32.log2());
let log2_10 = bf16::from_f32(core::f32::consts::LOG2_10);
let sqrt_2 = bf16::from_f32(core::f32::consts::SQRT_2);

assert_eq!(bf16::E, e);
Expand Down Expand Up @@ -1562,9 +1560,9 @@ mod test {
let one = bf16::from_f64(1.0);
let zero = bf16::from_f64(0.0);
let neg_zero = bf16::from_f64(-0.0);
let inf = bf16::from_f64(core::f64::INFINITY);
let neg_inf = bf16::from_f64(core::f64::NEG_INFINITY);
let nan = bf16::from_f64(core::f64::NAN);
let inf = bf16::from_f64(f64::INFINITY);
let neg_inf = bf16::from_f64(f64::NEG_INFINITY);
let nan = bf16::from_f64(f64::NAN);

assert_eq!(bf16::ONE, one);
assert_eq!(bf16::ZERO, zero);
Expand Down
49 changes: 24 additions & 25 deletions src/binary16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,8 @@ mod test {
let digits = ((f16::MANTISSA_DIGITS as f32 - 1.0) * 2f32.log10()).floor() as u32;
assert_eq!(f16::DIGITS, digits);
// sanity check to show test is good
let digits32 = ((core::f32::MANTISSA_DIGITS as f32 - 1.0) * 2f32.log10()).floor() as u32;
assert_eq!(core::f32::DIGITS, digits32);
let digits32 = ((f32::MANTISSA_DIGITS as f32 - 1.0) * 2f32.log10()).floor() as u32;
assert_eq!(f32::DIGITS, digits32);

// EPSILON
let one = f16::from_f32(1.0);
Expand All @@ -1580,7 +1580,7 @@ mod test {
// sanity check to show test is good
let one_plus_epsilon32 = f32::from_bits(1.0f32.to_bits() + 1);
let epsilon32 = one_plus_epsilon32 - 1f32;
assert_eq!(core::f32::EPSILON, epsilon32);
assert_eq!(f32::EPSILON, epsilon32);

// MAX, MIN and MIN_POSITIVE
let max = f16::from_bits(f16::INFINITY.to_bits() - 1);
Expand All @@ -1590,12 +1590,12 @@ mod test {
assert_eq!(f16::MIN, min);
assert_eq!(f16::MIN_POSITIVE, min_pos);
// sanity check to show test is good
let max32 = f32::from_bits(core::f32::INFINITY.to_bits() - 1);
let min32 = f32::from_bits(core::f32::NEG_INFINITY.to_bits() - 1);
let min_pos32 = 2f32.powi(core::f32::MIN_EXP - 1);
assert_eq!(core::f32::MAX, max32);
assert_eq!(core::f32::MIN, min32);
assert_eq!(core::f32::MIN_POSITIVE, min_pos32);
let max32 = f32::from_bits(f32::INFINITY.to_bits() - 1);
let min32 = f32::from_bits(f32::NEG_INFINITY.to_bits() - 1);
let min_pos32 = 2f32.powi(f32::MIN_EXP - 1);
assert_eq!(f32::MAX, max32);
assert_eq!(f32::MIN, min32);
assert_eq!(f32::MIN_POSITIVE, min_pos32);

// MIN_10_EXP and MAX_10_EXP
let ten_to_min = 10f32.powi(f16::MIN_10_EXP);
Expand All @@ -1605,12 +1605,12 @@ mod test {
assert!(ten_to_max < f16::MAX.to_f32());
assert!(ten_to_max * 10.0 > f16::MAX.to_f32());
// sanity check to show test is good
let ten_to_min32 = 10f64.powi(core::f32::MIN_10_EXP);
assert!(ten_to_min32 / 10.0 < f64::from(core::f32::MIN_POSITIVE));
assert!(ten_to_min32 > f64::from(core::f32::MIN_POSITIVE));
let ten_to_max32 = 10f64.powi(core::f32::MAX_10_EXP);
assert!(ten_to_max32 < f64::from(core::f32::MAX));
assert!(ten_to_max32 * 10.0 > f64::from(core::f32::MAX));
let ten_to_min32 = 10f64.powi(f32::MIN_10_EXP);
assert!(ten_to_min32 / 10.0 < f64::from(f32::MIN_POSITIVE));
assert!(ten_to_min32 > f64::from(f32::MIN_POSITIVE));
let ten_to_max32 = 10f64.powi(f32::MAX_10_EXP);
assert!(ten_to_max32 < f64::from(f32::MAX));
assert!(ten_to_max32 * 10.0 > f64::from(f32::MAX));
}

#[test]
Expand All @@ -1619,9 +1619,9 @@ mod test {
let zero = f16::from_f32(0.0);
let neg_zero = f16::from_f32(-0.0);
let neg_one = f16::from_f32(-1.0);
let inf = f16::from_f32(core::f32::INFINITY);
let neg_inf = f16::from_f32(core::f32::NEG_INFINITY);
let nan = f16::from_f32(core::f32::NAN);
let inf = f16::from_f32(f32::INFINITY);
let neg_inf = f16::from_f32(f32::NEG_INFINITY);
let nan = f16::from_f32(f32::NAN);

assert_eq!(f16::ONE, one);
assert_eq!(f16::ZERO, zero);
Expand Down Expand Up @@ -1681,9 +1681,9 @@ mod test {
let one = f16::from_f64(1.0);
let zero = f16::from_f64(0.0);
let neg_zero = f16::from_f64(-0.0);
let inf = f16::from_f64(core::f64::INFINITY);
let neg_inf = f16::from_f64(core::f64::NEG_INFINITY);
let nan = f16::from_f64(core::f64::NAN);
let inf = f16::from_f64(f64::INFINITY);
let neg_inf = f16::from_f64(f64::NEG_INFINITY);
let nan = f16::from_f64(f64::NAN);

assert_eq!(f16::ONE, one);
assert_eq!(f16::ZERO, zero);
Expand All @@ -1709,11 +1709,9 @@ mod test {
let ln_10 = f16::from_f64(core::f64::consts::LN_10);
let ln_2 = f16::from_f64(core::f64::consts::LN_2);
let log10_e = f16::from_f64(core::f64::consts::LOG10_E);
// core::f64::consts::LOG10_2 requires rustc 1.43.0
let log10_2 = f16::from_f64(2f64.log10());
let log10_2 = f16::from_f64(core::f64::consts::LOG10_2);
let log2_e = f16::from_f64(core::f64::consts::LOG2_E);
// core::f64::consts::LOG2_10 requires rustc 1.43.0
let log2_10 = f16::from_f64(10f64.log2());
let log2_10 = f16::from_f64(core::f64::consts::LOG2_10);
let sqrt_2 = f16::from_f64(core::f64::consts::SQRT_2);

assert_eq!(f16::E, e);
Expand All @@ -1731,6 +1729,7 @@ mod test {
assert_eq!(f16::LN_2, ln_2);
assert_eq!(f16::LOG10_E, log10_e);
assert_eq!(f16::LOG10_2, log10_2);
assert_eq!(f16::LOG10_2, log10_2);
assert_eq!(f16::LOG2_E, log2_e);
assert_eq!(f16::LOG2_10, log2_10);
assert_eq!(f16::SQRT_2, sqrt_2);
Expand Down
Loading