https://github.com/javadev/verylargenumber
The library to support very large number operations
https://github.com/javadev/verylargenumber
Last synced: 9 months ago
JSON representation
The library to support very large number operations
- Host: GitHub
- URL: https://github.com/javadev/verylargenumber
- Owner: javadev
- License: apache-2.0
- Created: 2015-03-04T05:46:23.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-03-31T18:11:34.000Z (over 1 year ago)
- Last Synced: 2025-01-31T08:32:58.094Z (11 months ago)
- Language: Java
- Size: 41 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# verylargenumber
[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.javadev%22%20AND%20a%3A%22verylargenumber%22)
[](https://travis-ci.org/javadev/verylargenumber)
[](https://coveralls.io/r/javadev/verylargenumber)
This library theoretically may support arithmetics for numbers with any number of digits, even thousands or millions (the number of digits is limited by abilities of client's JVM). This is simple implementation of school arithmetics rules and nothing more.
This library is named "Slowpoke" in honor of famous pokemon and because it's implementation is really slow and ugly, because author have not mattered about performance, memory consumption and multithreading in the 1st version. But real problem will be exposed by future stress tests.
How to use it?
Very simple:
String addResultStr = VeryLargeNumber.add(arg1Str, arg2Str);
String subResultStr = VeryLargeNumber.sub(arg1Str, arg2Str);
String mulResultStr = VeryLargeNumber.mul(arg1Str, arg2Str);
String divResultStr = VeryLargeNumber.div(arg1Str, arg2Str);
int compareResult = VeryLargeNumber.compareAbs(arg1Str, arg2Str);
If compareResult is zero, then numbers are equal. If compareResult is less than zero, the 1st number is less then 2nd. If compareResult is greater than zero, the 1st number is greater then 2nd.
In every case if argument is not parsable decimal number, it is treated as zero. If you try to divide by zero, method throws an exception.