Skip to content

Commit a641b05

Browse files
committed
core: updated for the master changes.
The master no longer has `std::num::Float`, so a generic `ldexp` is not readily available. `DecodableFloat::ldexpi` works around this.
1 parent 97ea7c1 commit a641b05

File tree

3 files changed

+96
-98
lines changed

3 files changed

+96
-98
lines changed

src/libcore/num/flt2dec/decoder.rs

+5
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,20 @@ pub enum FullDecoded {
5353

5454
/// A floating point type which can be `decode`d.
5555
pub trait DecodableFloat: Float + Copy {
56+
/// Returns `x * 2^exp`. Almost same to `std::{f32,f64}::ldexp`.
57+
/// This is used for testing.
58+
fn ldexpi(f: i64, exp: isize) -> Self;
5659
/// The minimum positive normalized value.
5760
fn min_pos_norm_value() -> Self;
5861
}
5962

6063
impl DecodableFloat for f32 {
64+
fn ldexpi(f: i64, exp: isize) -> Self { f as Self * (exp as Self).exp2() }
6165
fn min_pos_norm_value() -> Self { f32::MIN_POSITIVE }
6266
}
6367

6468
impl DecodableFloat for f64 {
69+
fn ldexpi(f: i64, exp: isize) -> Self { f as Self * (exp as Self).exp2() }
6570
fn min_pos_norm_value() -> Self { f64::MIN_POSITIVE }
6671
}
6772

src/libcoretest/num/flt2dec/estimator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::num::Float;
11+
use std::f64;
1212
use core::num::flt2dec::estimator::*;
1313

1414
#[test]
@@ -54,7 +54,7 @@ fn test_estimate_scaling_factor() {
5454
assert_almost_eq!(estimate_scaling_factor(0x1fffffffffffff, 971), 309);
5555

5656
for i in -1074..972 {
57-
let expected = Float::ldexp(1.0, i).log10().ceil();
57+
let expected = f64::ldexp(1.0, i).log10().ceil();
5858
assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16);
5959
}
6060
}

0 commit comments

Comments
 (0)