Important facts about commercial licenses

  • Licenses are perpetual. They do not expire and do not need to be renewed.
  • Licenses can be upgraded. You can upgrade to a more expensive license later paying only the difference in cost.
  • Pay attention to the distribution type - Hosted (sites / servers), binary (applications) or source (includes all the others). Choose according to your needs (more below).
  • All licenses allow commercial use unless otherwise indicated.
  • Read the full license by clicking on the icon.
  • Read more about licenses in our handy license guide.
Free

Demo Version

1 application Binary restricted distribution
$5

Personal License

1 application Binary restricted distribution Non-commercial use only No modifications
$9

Support Provided

1 application Binary restricted distribution 6 months support
$14

Developer License

Unlimited projects Source and binary distribution
You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

  • Released: Jul 22, 2011
    Last Update: Jul 24, 2011
  • Language: C/C++

Arbitrary-precision Decimal Class with Arithmetic Methods

Arbitrary-precision Decimal Class with Arithmetic Methods
Developed by Samuel Hiard, Released Jul 22, 2011

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

C/C++

Tags: arbitrary , arithmetic , class , decimal

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?

Back to top

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;
}
//----------------------------------------------------------------------

User Reviews

No reviews have been submitted yet.

Questions & Comments


Or enter your name and Email
No comments have been posted yet.
You must be logged-in to vote. Log-in to your account or register now.