forked from Alexhuszagh/rust-lexical
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Alexhuszagh#87 parsing hexfloats
Signed-off-by: max <[email protected]>
- Loading branch information
1 parent
28985e5
commit 62e40dc
Showing
4 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![cfg(all(feature = "format", feature = "power-of-two"))] | ||
|
||
use lexical_parse_float::{options::HEX_FLOAT, FromLexicalWithOptions}; | ||
use lexical_util::format::C_HEX_STRING; | ||
|
||
#[test] | ||
fn issue_87_test() { | ||
assert_eq!( | ||
f64::from_lexical_with_options::<{ C_HEX_STRING }>(b"1f.5p-2", &HEX_FLOAT), | ||
Ok(0x1f5 as f64 / (16 * 4) as f64) | ||
); | ||
assert_eq!( | ||
f64::from_lexical_with_options::<{ C_HEX_STRING }>(b"c2.a8p6", &HEX_FLOAT), | ||
Ok((0xc2a8 * (1 << 6)) as f64 / 256 as f64) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters