https://github.com/niten01/bignum
C++ library for long floating point arithmetics
https://github.com/niten01/bignum
cpp floating-point library long-arithmetics
Last synced: 11 months ago
JSON representation
C++ library for long floating point arithmetics
- Host: GitHub
- URL: https://github.com/niten01/bignum
- Owner: niten01
- License: mit
- Created: 2024-01-30T12:01:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-09T06:55:07.000Z (about 2 years ago)
- Last Synced: 2025-05-17T15:32:07.789Z (about 1 year ago)
- Topics: cpp, floating-point, library, long-arithmetics
- Language: C++
- Homepage:
- Size: 4.99 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BigNum
C++ library for long floating point arithmetics
## Example
```cpp
#include
#include
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;
}
```