-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Milestone
Description
Description
When parsing C-style hexadecimal floats (C_HEX_STRING
/HEX_FLOAT
) Lexical currently throws the following assertion failure in debug mode:
thread 'main' panicked at 'assertion failed: format.mantissa_radix() == format.exponent_base()', /home/tibor/.cargo/registry/src/mygithub.libinneed.workers.dev-1ecc6299db9ec823/lexical-parse-float-0.8.5/src/number.rs:60:9
Prerequisites
- Rust version:
rustc 1.64.0-nightly (3924dac7b 2022-07-29)
- lexical version:
6.1.1
- lexical compilation features used:
["parse-floats", "radix", "power-of-two", "format"]
Test case
fn main() {
let c_hex_float = "0x12.34p5"; // 582.5 in decimal
const FORMAT: u128 = lexical::format::C_HEX_STRING;
let options = &lexical::parse_float_options::HEX_FLOAT;
let (result, _) =
lexical::parse_partial_with_options::<f32, _, FORMAT>(c_hex_float, options).unwrap();
println!("{}: {}", c_hex_float, result);
}
Additional Context
I encountered this issue while working on reimplementing the strtof
and strtod
functions in Relibc (Redox C library) using Lexical.
Alexhuszagh and martinstuder