Giter Site home page Giter Site logo

rgroshanrg / bigint Goto Github PK

View Code? Open in Web Editor NEW
63.0 1.0 27.0 296 KB

bigint is a C++ library which can handle Very very Big Integers. It can calculate factorial of 1000000... it can go any big. It may be useful in Competitive Coding and Scientific Calculations which deals with very very large Integers. It can also be used in Decryption process. It has many inbuilt functions which can be very useful.

License: MIT License

C++ 100.00%
bigint biginteger-cpp biginteger cpp cpp11 biginteger-library cpp-library hactoberfest strings string-manipulation

bigint's People

Contributors

cs-mshah avatar minomy13 avatar oliverbooth avatar rgroshanrg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bigint's Issues

Ability to print a `bigint`.

Hey there! I would greatly appreciate some sort of ability to print these bigints. I'm not going to suggest how that could be implemented, because I'm not sure, but I figured I'd make an issue to point out that it would be useful ๐Ÿ˜„

Cannot cast and/or pass bigint type inside [ ]

Using Visual Studio C/C++

Trying to compute large factorials and permutation for n-th lexograohic permutation of arrays/strings.

Code segment:

memmove(buffer, digits, length * sizeof(element_t));

for (i = 0; i < length - 1; i++)
{
    scale /= (permutation_t)(length - i);
    d = index / scale;
    index %= scale;
    z = to_bigint(0);
    if (d > z) 
    {
        bigger_i = to_bigint(i);
        c = buffer[d + bigger_i];
        memmove(buffer + i + 1, buffer + i, smaller_d * sizeof(element_t));
        buffer[i] = c;
    }
}

Fails inside c = buffer[] line of code.

Severity Code Description Project File Line Suppression State
Error C2677 binary '[': no global operator found which takes type 'bigint' (or there is no acceptable conversion)

Top of code (compiles fine)

bigint permutation(element_t* const buffer,
const element_t* const digits,
const element_t length,
bigint index)
{
element_t c;
bigint d, z, scale, bigger_i;
element_t smaller_d, i;

if (!buffer || !digits || length < 1)
    return errno = EINVAL;

...

Please advise.

no operator "+" matches these operands; operand types are: const bigint + const bigint

For the following snippet:

const bigint a("1");
const bigint b("2");
std::cout << a + b << std::endl; // error in this line 

I am getting this error:

no operator "+" matches these operands
operand types are: const bigint + const bigint

Interestingly, removing const from a is resolving this error. I suspect you are internally changing the value of a.

Large division broken

I'm trying to divide 2 large integers, but after a certain point the quotient just becomes 0.

Ex 1:
bigint x("108165236279178312660610114131826512483935470542850824183737259708197206310322");
bigint y("10816523631251238799");
std::cout << "x / y = " << x / y << "\n";
gives 1111110100100100111001001010110100111011000110001110101000

Ex 2:
Adding just one extra integer ends up returning 0
bigint x("108165236279178312660610114131826512483935470542850824183737259708197206310322");
bigint y("108165236312512387996");
std::cout << "x / y = " << x / y << "\n";
gives 0

I've been looking for some kind of bigfloat library that could work, but haven't found any that supports division with such large integers. I'm working on an Elliptic Curve Cryptography implementation and need to divide two large integers (both the same size as x, but y around one digit shorter) for elliptic curve division. If anyone knows any libraries that support the division, I'd appreciate it a lot.

Thanks.

BigInt to String/Int/Long Long Int

I think you should also add methods which could help us to convert BigInt to primitive data types lke integer, string and long long int

cannot cast bigint to double

tried to cast two bigints to double in order to display their division result accordingly but vs complained no such function available

Had to add this to get it working

I use the single library file and it didn't work if I didn't had inline in front of all internal and public deinifition.
I use C++ 20 with Visual Studio 2022.

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.