Skip to content

Conversation

@headius
Copy link

@headius headius commented Dec 28, 2025

Several systems now allow for understands in numeric literals, so skip them if encountered.

This may be too permissive and will allow any number of underscores anywhere in the numeric part of the incoming string.

(I am attempting to adapt this library for use in JRuby's float parser, which must allow underscores.)

headius added a commit to headius/jruby that referenced this pull request Dec 28, 2025
This hooks up the Java implementation of Daniel Lemire's fast
float parsing algorithm to our internal float parsing logic,
excluding cases that are not 7-bit ASCII or which contain
underscore characters (not currently allowed by FDP, see
wrandelshofer/FastDoubleParser#85 for an attempt to add that
feature).
@wrandelshofer
Copy link
Owner

This class is specifically designed as a drop-in for the Java API Double.valueOf(String).
This is why, it only accepts the same syntax that is specified here: javadoc of Double.valueOf(String).

Ideally, you can use class ConfigurableDoubleParser instead.
Like so:

import ch.randelshofer.fastdoubleparser.ConfigurableDoubleParser;
import ch.randelshofer.fastdoubleparser.NumberFormatSymbols;

import java.util.Set;

public class MyMain {
    public static void main(String... args) {
        var parser = new ConfigurableDoubleParser(NumberFormatSymbols.fromDefault()
                .withGroupingSeparator(Set.<Character>of('_')));
        var result = parser.parseDouble("1_234.5e6");
        System.out.println(result);
    }
}

headius added a commit to headius/jruby that referenced this pull request Jan 7, 2026
This hooks up the Java implementation of Daniel Lemire's fast
float parsing algorithm to our internal float parsing logic,
excluding cases that are not 7-bit ASCII or which contain
underscore characters (not currently allowed by FDP, see
wrandelshofer/FastDoubleParser#85 for an attempt to add that
feature).
@headius
Copy link
Author

headius commented Jan 7, 2026

I can see that this does fix the issues for me, thank you! I withdraw my PR and we can continue discussion in jruby/jruby#9150.

@headius headius closed this Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants