Skip to content

Lolitron-0/BigNum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BigNum

C++ library for long floating point arithmetics

Example

#include <BigNum/BigNum.hpp>
#include <iostream>

using namespace bignum::literals;

int main()
{
    bignum::BigNum numFromString{ "-234.567" };
    bignum::BigNum numFromBaseType1{ 12345 };
    bignum::BigNum numFromBaseType2{ 12345.333 };
    // User-defined literals
    std::cout << 1_BN - 0.43_BN;
    std::cout << "6514.22"_BN;

    std::cout << 1 / numFromString; // Implicit conversions
    std::cout << numFromString.inverse();

    // 1000 digit precision (default 100)
    bignum::BigNum::setMinimalPrecision(1000);
    auto a{ -322.322_BN };
    bignum::BigNum b{ 121.21 };
    std::cout << a + b << std::endl;
    std::cout << a - b << std::endl;
    std::cout << a * b << std::endl;
    std::cout << a / b << std::endl;

    std::cout << (a < b) << std::endl;
    std::cout << (a >= b) << std::endl;
    std::cout << (a == b) << std::endl;
    std::cout << (a <=> b) << std::endl;
    return 0;
}

About

C++ library for long floating point arithmetics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published