Arbitrary-precision Decimal Class with Arithmetic Methods

Arbitrary-precision Decimal Class with Arithmetic Methods

Released 3 years ago , Last update 3 years ago

A C++ class for arithmetic operations on arbitrary-precision values

Have you ever noticed that double precision is not sufficient? Have you ever wanted your software to be able to compute 10^10 + 10^-10 ? If the answer is yes, then this component is definetely for you.

Based on a string representation, this class allows you to work with numbers without any limitations whatsoever on the number of digits being used.

You can perform simple arithmetics (+, -, *, /), to even more complex computations (power, sqrt)

This component is really easy to include in your project, compared to other solutions. So, why would you waste your time installing a whole package (like GMP) when you only want to be able to perform some operations on huge and/or tiny numbers?

Pricing

FREE

Demo Version

  • Perpetual license

  • 1 application

  • Can distribute binary products only

  • Commercial use

$9.99

Support Provided

  • Perpetual license

  • 1 application

  • Can distribute binary products only

  • Commercial use

  • 6 months support

$14.99

Developer License

  • Perpetual license

  • Unlimited projects

  • Can distribute code and binary products

  • Commercial use

Usage Example

#include 
using namespace std;
#include "BigDecimal.h"
//---------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{

BigDecimal testa("1234567812345678123456781.2345678");

cout << testa << endl;

string s("12387654321876543218765432187654322");
BigDecimal testb(s);

cout << testb << endl;

testa = BigDecimal("1234.544");
testb.setString("1123.456");
cout << testa + testb << endl;
cout << testa - testb << endl;
cout << testb - testa << endl;
cout << testa + (-testb) << endl;

cout << testa * testb << endl;

cout << testa / testb << endl;
cout << testb / testa << endl;

cout << BigDecimal(4)/3 << endl;

cout << BigDecimal("54321.1234")%5 << endl;

cout << BigDecimal("-54")%14 << endl;

cout << (testa^8) << endl;
cout << (testa^-4) << endl;

++testa = 5;
cout << testa++ << endl;
cout << ++testa << endl;
--testa = 5;
cout << testa-- << endl;
cout << --testa << endl;

testa = BigDecimal("1234.544");

testa += testb;
cout << testa << endl;

testa -= testb;
cout << testa << endl;

testa *= testb;
cout << testa << endl;

testa /= testb;
cout << testa << endl;

testa %= testb;
cout << testa << endl;

testa ^= 5;
cout << testa << endl;

cout << sqrt(testa) << endl;

getchar();

return 0;
}
//----------------------------------------------------------------------
4 licenses, starting from From » FREE View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
No comments have been posted yet.