Sitemap
1 min readOct 24, 2017

BigDecimal implementation in OpenJDK is very well written and quite fast, compared to other similar libraries. There is no much reason to reimplement it. It is very hard to do a general-purpose (sic!) arbitrary precision arithmetics library that is so fast. Engineers who wrote it did a very good job.

However, you can do better if you don’t need a general-purpose library, but have some particular set of constraints. For example, in this repo https://github.com/elizarov/MunchausenNumbers I implemented an Int96 integer type based on 3 ints to solve the problem I had at hand (the problem is explained in readme). Using a general-purpose BigInteger type was too slow. It still took a couple of days on my machine to find a solution, whereas with BigInteger I had no chance to arrive at the answer in a reasonable time.

Roman Elizarov
Roman Elizarov

Written by Roman Elizarov

Project Lead for the Kotlin Programming Language @JetBrains

No responses yet