]> ocean-lang.org Git - ocean-D/blobdiff - Ocean-numbers
updates
[ocean-D] / Ocean-numbers
diff --git a/Ocean-numbers b/Ocean-numbers
new file mode 100644 (file)
index 0000000..85b78b3
--- /dev/null
@@ -0,0 +1,48 @@
+Numeric types in ocean...
+
+Currently (nov 2021) I have 'number' which is arbitrary precision rational.
+
+I obviously need more.
+
+I need to be able to specify range of numbers, at least in structs/arrays.
+This includes:
+   number of bits, or maximum
+   whether signed
+   floating-point options
+
+I need to know if overflow wraps, clips, or errors.
+Certainly I need cyclic unsigned numbers.
+Others probably need to report an error if correctness cannot
+be proved.
+Errors can be ignored, but this must be explicit.
+
+So: integer, natural, cyclic, floating
+
+These can abbreviate to 3 letters or 1 with a number 
+  int nat i8 c32 f32 f64
+
+Units can be included as suffix of literal (30cm) or attribute of
+type (i32/cm)
+units and combinations are declared
+ units cm kg m/s=mps
+addition requires matching units or unitless
+multiplication combines units if known to be valid
+
+Track range of varables and decide type based on range when not explicit?
+
+Need a notion of flag sets
+
+set foo
+  bar, bat, bat
+
+x : foo
+.bar can be added to or remove from x
+x.bar tests and can be assigned like a bool.
+x + .bat can set
+
+
+enum bar
+  a, b, c
+
+can use .a when context confirms type
+