My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads

SLI (symmetric level-index) arithmetic essentially prevents overflow & underflow in computing. With this library, you may use 'SLI' as a normal data type in C++. Replace 'double' with 'SLI' in you program, and over/underflow problem would be solved.

It supports operations including +, -, *, /, ==, !=, <, >, <=, >=, +=, -=, *=, /=, exp, log(base e, 2 & 10), pow, sqrt, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, <<... Mixed operations with other data types also work.

The above operations were optimized as far as I could. A systematic testing was performed to ensure their correctness.

Some extended arithmetic operations were added later, such as the sum of N arguments, vector norm, and dot product.

Here are a few simple examples:

Example 1 -- 1.432e32 * 4.432e25

Code:

SLI a, b, c;
a = 1.432e32;
b = 4.432e25;
c = a * b;
cout << c << endl;

Result: 6.346624e+057

Example 2 --

-1.432e102 / 3.213e-232
-1.432e102 ^ 4432321

Code:

SLI a, b, c, d, e;
a = -1.432e102;
b = 4432321;
c = 3.213e-232;
d = a / c;
e = pow(a, b);
cout << d << endl;
cout << flpout << d << endl;
cout << sliout << e << endl;
cout << flpout << e << endl;

Result:

(4, -0.638549784525709)
-4.45689386865738 * 10 ^ 333
(5, -0.104035953299704)
-3.26108314099633 * 10 ^ 452787931

For more information about SLI arithmetic, please refer to http://www.sliarithmetic.net

Copyright (C) 2007 Xunyang Shen

Email: xunyang.shen at gmail.com

Powered by Google Project Hosting