2009-12-28

num.type

10.9: adda/type"num/integer division:
. it's amazing how stiff c and python are with division;
it should be like this:
if you really want integer division,
use a special operator;
eg, the one math uses when asking the truth of
whether x1 is an integer multiple of x2:
x1 | x2 .
. if doing a division on integers
it should convert ints to rationals for you .

10.22: adda/type"ir (num's irrational subtype):
. type"num saves value without eval'ing /, ir' symbols;
then to force an eval', typecast it as float, q, etc;
or, assign to a var constrained to float, q, etc .
. part of num'mgt is regrouping factors to save space:
2pi + x pi implies (2+x) pi,
--. for every addend having a unique combo of ir's
that is how long the list has to be .
. a combo of ir's can be efficiently impl'd as a bit vector;
then it's limited to representing {32, 64} ir' const's .


10.23: adda/type"num/Q is the new float:

. float is not really needed except when
clients or servers expect them;
they are an approximation of reals,
and Q's can serve this function .

. if not worried about conserving size
thereby allowing a single size of memory for all subtypes,
then they could all be impl'd with 4 longs .
high precision float:
(frac#1, frac#2, frac#3, exp)
Q with Q-style exponent:
(val.numer, val.denum, exp.numer, exp.denum)

. one of the longs can use a bit field to hold a type tag,
so that the use of the longs can be specialized to the subtype .
[10.24:
. impl'ing the tag that way,
then the size could vary without messing up allignments .
]

11.15: adda/type"number/significance tracking:
. significance needs to be part of number
. it might be most efficient to just
double-float all operations for speed
but it needs to come with a [significant digits count]
and have that applied to the final result
unless exact arithmetic was used .