A simple implementation of the multiple precision arithmetic.
Overview
I have developed a "KFloat" class, which supports multiple precision arithmetic.
Just simply the most important and basic purpose of the computer is a calculation.
The KFloat class is a simple basic implementation of the long digit number.
The features are as follows:
-
Represent 1 digit in 1 byte. Max length of digit is 2^32.
-
Addition, Subtraction, Multiplication, Division
-
Sqrt, nth-roots, power, exp, ln, log, sin, cos, tan, factorial
-
pi, e
This class is embedded in the KWLib-script.
Algorithms
I'm planning to explain algorithms. Please wait for a while.
Sample result (40 digits)
I checked these values against Mathematica.
sqrt(2): 1.41421356237309504880168872420969807856
sqrt(3): 1.73205080756887729352744634150587236694
10(2nd root): 3.16227766016837933199889354443271853372
10(3rd root): 2.15443469003188372175929356651935049526
10(4th root): 1.77827941003892280122542119519268484473
e: 2.71828182845904523536028747135266249775
ln(2): 0.693147180559945309417232121458176568075
ln(10): 2.30258509299404568401799145468436420760
ln(20): 2.99573227355399099343522357614254077567
ln(20000): 9.90348755253612804548919794019563339847
log(2): 0.301029995663981195213738894724493026768
exp(2): 7.38905609893065022723042746057500781286
exp(25): 72004891385.8970041085186672888694478298
2^0.5: 1.41421356237309504880168872420969807856
pi: 3.14159265358979323846264338327950288419
Factorials:
0!=1
1!=1
2!=2
3!=6
4!=24
5!=120
6!=720
7!=5040
8!=40320
9!=362880
10!=3628800
11!=39916800
12!=479001600
13!=6227020800
14!=87178291200
15!=1307674368000
16!=20922789888000
17!=355687428096000
18!=6402373705728000
19!=121645100408832000
20!=2432902008176640000
21!=51090942171709440000
22!=1124000727777607680000
23!=25852016738884976640000
24!=620448401733239439360000
25!=15511210043330985984000000
26!=403291461126605635584000000
27!=10888869450418352160768000000
28!=304888344611713860501504000000
29!=8841761993739701954543616000000
sin(1): 0.841470984807896506652502321630298999622
cos(1): 0.540302305868139717400936607442976603732
tan(1): 1.55740772465490223050697480745836017308