Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit f6b1122

Browse files
committed
Util: also print the hex float format for outputs
1 parent b00ec04 commit f6b1122

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/util/src/main.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::env;
88
use std::num::ParseIntError;
99
use std::str::FromStr;
1010

11-
use libm::support::{hf32, hf64};
11+
use libm::support::{Hexf, hf32, hf64};
1212
#[cfg(feature = "build-mpfr")]
1313
use libm_test::mpfloat::MpOp;
1414
use libm_test::{MathOp, TupleCall};
@@ -73,7 +73,7 @@ macro_rules! handle_call {
7373
}
7474
_ => panic!("unrecognized or disabled basis '{}'", $basis),
7575
};
76-
println!("{output:?}");
76+
println!("{output:?} {:x}", Hexf(output));
7777
return;
7878
}
7979
};
@@ -303,6 +303,10 @@ impl FromStrRadix for i32 {
303303
#[cfg(f16_enabled)]
304304
impl FromStrRadix for f16 {
305305
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> {
306+
if radix == 16 && s.contains("p") {
307+
return Ok(libm::support::hf16(s));
308+
}
309+
306310
let s = strip_radix_prefix(s, radix);
307311
u16::from_str_radix(s, radix).map(Self::from_bits)
308312
}
@@ -334,6 +338,9 @@ impl FromStrRadix for f64 {
334338
#[cfg(f128_enabled)]
335339
impl FromStrRadix for f128 {
336340
fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> {
341+
if radix == 16 && s.contains("p") {
342+
return Ok(libm::support::hf128(s));
343+
}
337344
let s = strip_radix_prefix(s, radix);
338345
u128::from_str_radix(s, radix).map(Self::from_bits)
339346
}

0 commit comments

Comments
 (0)