]> ocean-lang.org Git - ocean-D/blob - Numbers-impl
updates
[ocean-D] / Numbers-impl
1
2 Implementation of numbers in the language interp/compiler
3
4 I really like Go's typeless constants.  i.e. compile-time numbers are
5 arbitrary precision. It is only when we write them into the executable
6 that a size must be set.
7
8 So we need a data structure that can hold any number, whether integer
9 or float, with complete decimal or binary precision.
10 A large integer together with large binary and decimal exponents would
11 do it.
12 How large do we make the integer?  An array of integers?
13
14 How precise do we make division?  Go doesn't try too hard.
15
16 We could keep a rational number. So large-int for numerator and
17 denominator, and 'int' for exponent and power.
18
19 Then we need add, subtract, multiply, GCD, divide for large-int,
20 and add, subtract, multiply, divide for scaled rational.