Giter Site home page Giter Site logo

Comments (5)

wrandelshofer avatar wrandelshofer commented on June 19, 2024

Thank you for the test cases!
Most of them were caused by wrong treatment of unsigned longs in the code. I have fixed those.
I am going to look at the remaining ones next.

from fastdoubleparser.

wrandelshofer avatar wrandelshofer commented on June 19, 2024

Another class of inputs were wrong because the code did not compensate for skipped digits if there are more than 19 digits.

from fastdoubleparser.

lemire avatar lemire commented on June 19, 2024

For long inputs, the recommended approach is as follows:

https://github.com/fastfloat/fast_float/blob/main/include/fast_float/parse_number.h#L111-L116

Also in C# at

https://github.com/CarlVerret/csFastFloat/blob/0281cc1bd6f617fa4e1741e4f8c60ceb9fc33fdf/csFastFloat/FastDoubleParser.cs#L380-L390

See section 11 in https://arxiv.org/pdf/2101.11408.pdf

from fastdoubleparser.

wrandelshofer avatar wrandelshofer commented on June 19, 2024

Thank you very much for the pointers to the corresponding code sections!

3be8131 includes now the code that you have marked in https://github.com/fastfloat/fast_float/blob/main/include/fast_float/parse_number.h#L111-L116.

When that fails, the code currently falls back to java.lang.Double.parseDouble(), so that all test cases should pass now.

I am planning to replace all fall back calls to Double.parseDouble() in upcoming commits.

For decimal floating point literals, I believe, it is best to port the parse_long_mantissa function from your C++ code, and everything that comes with it. Your class "decimal" appears to do the stuff that I need. (I tinkered with class java.math.BigDecimal. But it round-trips to a String which it then feeds into Double.parseDouble for doing the conversion - which kind of defeats the purpose).

I am not sure how to implement the corresponding cases for hexadecimal floating point literals. In this case, we have a number that is composed of 1^sign * mantissa * 2^exponent. I tried with the class java.math.BigInteger, but memory usage was too high. Thats why in 3be8131 the code currently only tries Clingers fast path, and then immediately falls back to Double.parseDouble.

from fastdoubleparser.

wrandelshofer avatar wrandelshofer commented on June 19, 2024

This is fixed in ac66003

This revision includes a port of the Decimal class from the C++ code in fast_float. However, it turns out that the code in OpenJDK class jdk.internal.math.FloatingDecimal is by at least by one order of magnitudes faster. So performance is better if method parseRestOfDecimalFloatLiteralTheHardWay() in FastDoubleParser just calls Double.parseDouble().

from fastdoubleparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.