diff options
| author | Trevor Gross <tmgross@umich.edu> | 2025-01-28 10:09:27 +0000 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2025-01-29 00:17:19 +0000 |
| commit | e283c25602a7ab12ea8e4b62db1fe18c4678da1f (patch) | |
| tree | b7107a1e107d55fc67a2023fd664927984b6ef4f | |
| parent | f767b58ba4fad1e8184f699dad5eb83734a5346d (diff) | |
| download | rust-e283c25602a7ab12ea8e4b62db1fe18c4678da1f.tar.gz rust-e283c25602a7ab12ea8e4b62db1fe18c4678da1f.zip | |
Util: also print the hex float format for outputs
| -rw-r--r-- | library/compiler-builtins/libm/crates/util/src/main.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/library/compiler-builtins/libm/crates/util/src/main.rs b/library/compiler-builtins/libm/crates/util/src/main.rs index 6ea1be3d9ae..357df6b4fe2 100644 --- a/library/compiler-builtins/libm/crates/util/src/main.rs +++ b/library/compiler-builtins/libm/crates/util/src/main.rs @@ -8,7 +8,7 @@ use std::env; use std::num::ParseIntError; use std::str::FromStr; -use libm::support::{hf32, hf64}; +use libm::support::{Hexf, hf32, hf64}; #[cfg(feature = "build-mpfr")] use libm_test::mpfloat::MpOp; use libm_test::{MathOp, TupleCall}; @@ -73,7 +73,7 @@ macro_rules! handle_call { } _ => panic!("unrecognized or disabled basis '{}'", $basis), }; - println!("{output:?}"); + println!("{output:?} {:x}", Hexf(output)); return; } }; @@ -303,6 +303,10 @@ impl FromStrRadix for i32 { #[cfg(f16_enabled)] impl FromStrRadix for f16 { fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> { + if radix == 16 && s.contains("p") { + return Ok(libm::support::hf16(s)); + } + let s = strip_radix_prefix(s, radix); u16::from_str_radix(s, radix).map(Self::from_bits) } @@ -334,6 +338,9 @@ impl FromStrRadix for f64 { #[cfg(f128_enabled)] impl FromStrRadix for f128 { fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError> { + if radix == 16 && s.contains("p") { + return Ok(libm::support::hf128(s)); + } let s = strip_radix_prefix(s, radix); u128::from_str_radix(s, radix).map(Self::from_bits) } |
