Giter Site home page Giter Site logo

Comments (11)

eobermuhlner avatar eobermuhlner commented on June 3, 2024 1

I have a first version of toBigDecimal(String) committed.

toBigDecimal(String) to 2000
toBigDecimal(String) to 10000

from big-math.

plokhotnyuk avatar plokhotnyuk commented on June 3, 2024 1

And finally, PRs with using of your idea for BigInt and BigDecimal where I got O(n^1.5) complexity for numbers that are greater than 10000.

Thank you, a lot!

from big-math.

plokhotnyuk avatar plokhotnyuk commented on June 3, 2024

Ups... JDK 8/11 already use it for toString and the complexity measured by benchmarks looks like O(n*sqrt(n))... So feel free to close the issue if the approach is not applicable for parsing of BigInt which still has O(n^2) complexity for numbers with n=10000 and above.

from big-math.

eobermuhlner avatar eobermuhlner commented on June 3, 2024

Thanks for the hint.

My measurements show that at least the BigDecimal(String) constructor is O(n^2) so I will implement a split recursive version.
First experiments have been promising but I will need to get all the parsing details right.

from big-math.

plokhotnyuk avatar plokhotnyuk commented on June 3, 2024

Eric, what a great work!

Will you grant to adopt key part of your solution in jsoniter-scala parser for BigDecimal?

from big-math.

eobermuhlner avatar eobermuhlner commented on June 3, 2024

from big-math.

plokhotnyuk avatar plokhotnyuk commented on June 3, 2024

Another idea for optimization of parsing of java.math.BigDecimal values would be taking into account a math context to avoid calculation of the lower part which will be rounded off.

Yeah, for general case it is a crazy idea, but it would worth for the most used HALF_EVEN rounding mode.

from big-math.

eobermuhlner avatar eobermuhlner commented on June 3, 2024

from big-math.

plokhotnyuk avatar plokhotnyuk commented on June 3, 2024

Here is a PR with ~2x times faster parsing of BigInteger values. The algorithm still has O(n^2) complexity, just a redundant nested loop for the addition was removed.

from big-math.

plokhotnyuk avatar plokhotnyuk commented on June 3, 2024

But we still have a chance to move closer to the theoretical limit using one of proposed method for the integer multiplication in time O(n log n) [pdf] https://t.co/IltaboOoUq

from big-math.

plokhotnyuk avatar plokhotnyuk commented on June 3, 2024

Also, using of BigDecimal.valueOf gives more than 25% increase for parsing speed of small (up to 128 bits) BigInteger values

from big-math.

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.