|
Good day, Ladies and Gents
I am writing some tool to deal with precise numbers. This of course implies that I store and manipulate precise numbers. I am looking for a suitable format for storing such numbers concisely in a computer's memory.
This is how far I have come (the symbol "|" being used as "exclusive or"):
Let N be a 4-tupel {s,n,d,f}
where
s is the sign (-1 if neg|0|1 if pos)
n is the numerator
d is the denominator
f are a collection of distinct binary flags being 1 when a certain irrational mathematical factor is present and 0 otherwise, e.g.
The flags ...eipf could indicate ...e, i, pi, phi
Then the binary value ...1010 would indicate the presence of the factors e*pi
Examples of numbers written in such 4-tupels N:
3 = {1,3,1,...0000}
-pi/4 = {-1,1,4,...0010}
Taking this a step further we include roots and powers (using "^" as the exponentiation symbol, and "[...]" to indicate optionality), and N1, N2, N3... to indicate the 4-tupels):
E=N1[^N2[^N3[...[^Nn]]]]
Examples:
(pi/2)^4 = {1,1,2,...0010}^{1,4,1,...0000}
sqrt(3) = {1,3,1,...0000}^{1,1,2,...0000}
(3e)^(i*pi) = {1,3,1,...1000}^{1,1,1,...0110}
Now, if we also allow factors of such exponents E:
E1[*E2[*E3[...[*En]]]]
(needed because E alone could not handle for example 3sqrt(2)e^p )
then I think that I can store every possible number in a concise and *precise* format.
But I am not sure and am looking for your input (mainly looking for a counter-example, actually).
Thanks in advance for your time
//Donar
|