Version 7 of MPA

Updated 2004-01-27 08:55:52

Acronym for Multiple Precision Arithmetics. Library in pure Tcl available at : http://sarnold.free.fr/


Examples

with a 333MHz PII 100MHz PCI Bus PC with Windows Me.

 (mpa-v0.11) 50 % package require mpa
 0.11
 (mpa-v0.11) 51 % mpa::int::add 111111111111111111111 98237827463784678346478
 98348938574895789457589
 (mpa-v0.11) 52 % mpa::int::add 1000000000000000000000 99999999999999999
 1000099999999999999999
 (mpa-v0.11) 53 % mpa::int::mul 1001 9009
 9018009
 (mpa-v0.11) 54 % mpa::int::mul 10010001 9009009
 90180189099009
 (mpa-v0.11) 55 % mpa::float::pi 20
 # Pi constant with 20 decimals, the result is cached in a namespace variable
 3.14159265358979323846
 (mpa-v0.11) 56 % time {mpa::float::pi 20};# result is cached in memory
 363 microseconds per iteration
 (mpa-v0.11) 57 % time {mpa::float::pi 21};# result is now recomputed
 90643 microseconds per iteration
 (mpa-v0.11) 58 % time {puts [mpa::float::pi 21]};# result is cached
 3.141592653589793238462
 4962 microseconds per iteration
 (mpa-v0.11) 59 % mpa::float::add 1.0 2.0
 3.0~2 # the precision with 1.0 ans 2.0 is assumed to be 0.1 
 # and the precision of the sum is the sum of the precisions
 (mpa-v0.11) 60 % mpa::float::add 1.0000 2.0000
 3.0000~2
 (mpa-v0.11) 62 % mpa::float::format [mpa::float::mul 1.0000000 2.000000];
 # the precision of the product is approximatly max(A*Pb,B*Pa) = 2*0.00000001 = 2e-7
 2.00000 # now the number is formatted to be put on screen
 (mpa-v0.11) 63 % mpa::float::mul 1.0000000 2.000000
 2.000000~2 # precision is computed to be always the smallest ,
 # even if such computations are complex to handle and loss of CPU

Category Mathematics | Category Acronym | Category Package