Skip to content

Add parse_float facilities#1

Merged
phorward merged 12 commits into
mainfrom
parsefloat
Jul 20, 2026
Merged

Add parse_float facilities#1
phorward merged 12 commits into
mainfrom
parsefloat

Conversation

@phorward

@phorward phorward commented Oct 2, 2024

Copy link
Copy Markdown
Owner

This pull request should add support for floating point numbers to the num-parse-crate.

The branch is already open for a while, and there is a problem with the precision, which shall be equal to the one reached by Rust directly.

The problem is this test, where -1337.0e-298f64 works but -1337.0e-299f64 fails in precision (assertion left == right failed; left: Some(-1.3369999999999998e-296); right: Some(-1.337e-296))

assert_eq!(parse_float::<f64>(" -1337.0e-296f64 "), Some(-1337.0e-296f64));  // OK
assert_eq!(parse_float::<f64>(" -1337.0e-297f64 "), Some(-1337.0e-297f64));  // FAIL

phorward added 7 commits July 9, 2022 15:29
This is a naive approach for a parse_float() that was implemented in Tokay already. See the comment in float.rs for details on how this isn't the best.
Still not equal to Rust's f64 literals, yet.
Still not perfect - the rounding glitches.
@phorward phorward added enhancement New feature or request help wanted Extra attention is needed labels Oct 2, 2024
@phorward phorward removed the help wanted Extra attention is needed label Jul 20, 2026
@phorward
phorward marked this pull request as ready for review July 20, 2026 14:05
@phorward
phorward merged commit e988030 into main Jul 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant