Hi,
Discovered a couple of gems. One gem are the BigDecimals.
It seems that they not only offer unlimited precision
calculations, as can be seen here:
?- X is 0d1.23 * 0d4.56.
X = 0d5.6088
But all the arithmetic Java methods such as multiple()
etc.. have a variant where we can pass a math context
as an additional argument which defines some rounding.
These additional functions can be made accessible via
an evaluable functions vpa/2. This evaluable function is
special, since it does't directly evaluate its first
argument. Instead it crawls through the first argument,
and replaces all unlimited precision calculations by
some limited precision calculations:
?- X is vpa(0d1.23 * 0d4.56, 3).
X = 0d5.61
What can be done except +, -, *, / with these variant
methods? Well we embarked on implementing sin, cos, atan,
exp, log and are almost done, here are some examples:
?- X is vpa(exp(100000), 32).
X = 0d2.8066633604261231793183858327690E+43429
?- X is vpa(log(exp(100000)), 30).
X = 0d100000.000000000000000000000001
?- X is vpa(log(exp(100000)), 31).
X = 0d99999.99999999999999999999999995
?- X is vpa(log(exp(100000)), 32).
X = 0d100000.00000000000000000000000000
The BigDecimals have an amazing breadth when the mantissas
is resricted by a given precision. The exponent can be easily
bigger than what the new Windows 10 calculator allows.
Have a Nice day!
Short description: Variable Precission Functions in Prolog
https://plus.google.com/u/0/b/103259555581227445618/+JekejekeCh/posts/dLpzvJ2BrRj
Sourc code: Gist Source Code of sin, cos, atan, etc..
https://gist.github.com/jburse/a209b1fab191964adbd3eb15539b188c#file-trans-p