All Projects → axelheer → nein-math

axelheer / nein-math

Licence: MIT license
NeinMath is playing around with arbitrary precision integers, written in pure managed code, not using any unsafe stuff, and a bit faster than the build-in .NET type for integers with a few thousand bits.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to nein-math

BhimIntegers
BhimIntegers🚀 is a C++ library that is useful when we are dealing with BigIntegers💥💥. We can handle big integers (integers having a size bigger than the long long int data type) and we can perform arithmetic operations📘 like addition, multiplication, subtraction, division, equality check, etc📐📐. Also, there are several functions like factorial, …
Stars: ✭ 43 (+207.14%)
Mutual labels:  biginteger, bignumber
break infinity.js
A replacement for decimal.js for incremental games who want to deal with very large numbers (bigger in magnitude than 1e308, up to as much as 1e(9e15) ) and want to prioritize speed over accuracy.
Stars: ✭ 145 (+935.71%)
Mutual labels:  biginteger, bignumber
klibcpp
kedixa's Cplusplus Library(timer, multiarray, unsigned_bigint, bigint, rational)
Stars: ✭ 17 (+21.43%)
Mutual labels:  biginteger, bignumber
BigInteger
Be limited not by the size of your register but by the bulk of your RAM.
Stars: ✭ 13 (-7.14%)
Mutual labels:  biginteger, bignumber
BigNumber
A really long long long long long long number in C++
Stars: ✭ 37 (+164.29%)
Mutual labels:  biginteger, bignumber
UInt256
An UInt256 library written in Swift 4
Stars: ✭ 20 (+42.86%)
Mutual labels:  biginteger
vallang
Generic immutable recursive data representation API targeted at source code models and more.
Stars: ✭ 28 (+100%)
Mutual labels:  biginteger
Decimal.js
An arbitrary-precision Decimal type for JavaScript
Stars: ✭ 4,585 (+32650%)
Mutual labels:  bignumber
Decimal
Arbitrary-precision fixed-point decimal numbers in go
Stars: ✭ 3,588 (+25528.57%)
Mutual labels:  bignumber
biginteger
A PHP library to work with big integers.
Stars: ✭ 19 (+35.71%)
Mutual labels:  biginteger
VBCorLib
The VBCorLib framework brings many of the powerful .NET classes to VB6.
Stars: ✭ 81 (+478.57%)
Mutual labels:  biginteger
swift-numberkit
Advanced numeric data types for Swift 5, including BigInt, Rational, and Complex numbers.
Stars: ✭ 47 (+235.71%)
Mutual labels:  biginteger
bytes-java
Bytes is a utility library that makes it easy to create, parse, transform, validate and convert byte arrays in Java. It supports endianness as well as immutability and mutability, so the caller may decide to favor performance.
Stars: ✭ 120 (+757.14%)
Mutual labels:  biginteger
Bignumber.js
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
Stars: ✭ 5,174 (+36857.14%)
Mutual labels:  bignumber
Base62
PHP Base62 encoder and decoder for integers and big integers with Laravel 5 support.
Stars: ✭ 16 (+14.29%)
Mutual labels:  biginteger
Big.js
A small, fast JavaScript library for arbitrary-precision decimal arithmetic.
Stars: ✭ 3,730 (+26542.86%)
Mutual labels:  bignumber
id-mask
IDMask is a Java library for masking internal ids (e.g. from your DB) when they need to be published to hide their actual value and to prevent forging. It has support optional randomisation has a wide support for various Java types including long, UUID and BigInteger. This library bases its security on strong cryptographic primitives.
Stars: ✭ 39 (+178.57%)
Mutual labels:  biginteger
Swift-MathEagle
A general math framework to make using math easy. Currently supports function solving and optimisation, matrix and vector algebra, complex numbers, big int, big frac, big rational, graphs and general handy extensions and functions.
Stars: ✭ 41 (+192.86%)
Mutual labels:  biginteger
intx
intx – extended precision integer library
Stars: ✭ 83 (+492.86%)
Mutual labels:  biginteger
as-bignum
Fixed length big numbers for AssemblyScript 🚀
Stars: ✭ 49 (+250%)
Mutual labels:  biginteger

NeinMath

Latest package Download tracker GitHub status Code coverage

NeinMath is playing around with arbitrary precision integers, written in pure managed code, not using any unsafe stuff, and a bit faster than the build-in .NET type for integers with a few thousand bits.

To install NeinMath, run the following command in the NuGet Package Manager Console.

PM> Install-Package NeinMath

It's generally based on the integer implementation of this work, but rewritten to not use pointer arithmetic and other fancy things. Thus, it's a bit slower albeit portable.

Note: starting with the new .NET Core this project becomes a bit obsolete, because the performance gains disappear since some improvements have been contributed. 🎉

Performance

Let's start with a simple comparison (time per 100 operations).

Operation Length (bits) BigInteger (.NET) Integer (NeinMath)
log 4,194,304 1306 ms 0 ms
add (+) 4,194,304 40 ms 17 ms
sub (-) 4,194,304 43 ms 18 ms
mul (*) 65,536 980 ms 116 ms
squ (^2) 65,536 980 ms 82 ms
div (/) 65,536 555 ms 231 ms
mod (%) 65,536 555 ms 231 ms
gcd 65,536 730 ms 532 ms
modinv 65,536 N/A 1,412 ms
modpow 16,384 5,124,600 ms 652,900 ms

Note: ensure you're running a 64-bit process. Handling this with just 32-bits is a huge impediment for both, BigInteger and Integer.

Note: these results are from "my machine". A basic (very basic) benchmark utility is included to verify / disprove them.

Integers

Like BigInteger a structure Integer provides all the operators you would expect from an integer, so it should be quite compatible to existing .NET code. In fact, there are tests based on BigInteger to ensure it computes correctly most of the time.

To get an idea, this is an example for calculating the Greatest Common Divisor:

Integer Gcd(Integer left, Integer right)
{
    var a = left.Abs();
    var b = right.Abs();

    while (b != 0)
    {
        var c = a % b;
        a = b;
        b = c;
    }

    return a;
}

Note: calling left.Gcd(right) is much faster, since the internal implementation is based on a more sophisticated algorithm.

Rationals

Coming sometime... maybe... who knows?

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].