]> ocean-lang.org Git - ocean-D/blob - Ocean-numbers
updates
[ocean-D] / Ocean-numbers
1 Numeric types in ocean...
2
3 Currently (nov 2021) I have 'number' which is arbitrary precision rational.
4
5 I obviously need more.
6
7 I need to be able to specify range of numbers, at least in structs/arrays.
8 This includes:
9    number of bits, or maximum
10    whether signed
11    floating-point options
12
13 I need to know if overflow wraps, clips, or errors.
14 Certainly I need cyclic unsigned numbers.
15 Others probably need to report an error if correctness cannot
16 be proved.
17 Errors can be ignored, but this must be explicit.
18
19 So: integer, natural, cyclic, floating
20
21 These can abbreviate to 3 letters or 1 with a number 
22   int nat i8 c32 f32 f64
23
24 Units can be included as suffix of literal (30cm) or attribute of
25 type (i32/cm)
26 units and combinations are declared
27  units cm kg m/s=mps
28 addition requires matching units or unitless
29 multiplication combines units if known to be valid
30
31 Track range of varables and decide type based on range when not explicit?
32
33 Need a notion of flag sets
34
35 set foo
36   bar, bat, bat
37
38 x : foo
39 .bar can be added to or remove from x
40 x.bar tests and can be assigned like a bool.
41 x + .bat can set
42
43
44 enum bar
45   a, b, c
46
47 can use .a when context confirms type
48