shoooe / Inom

A numeric library with some static guarantees. WARNING: This project is abandoned due to the fact that a library that does exactly the same thing, few years ahead of this one, already exists: https://bitbucket.org/davidstone/bounded_integer.
0 stars 0 forks source link

Add modulus operator (%) #14

Open shoooe opened 9 years ago

shoooe commented 9 years ago

Add modulus operator (%)

shoooe commented 9 years ago

This is actually very interesting. Modulus cannot be represented with out current (domain is only between 1 range of values). For example:

x : [18, 23]
y : [16, 19]
x % y : [0, 7] U [18, 18]

So this means that we have to be able to specify domains with multiple ranges, before going forward.

shoooe commented 9 years ago

Oh and multiple ranges have this very nice effect:

x : [0, 10] ∪ [15, 15]
y : [45, 52] ∪ [67, 90]
x * y : [0, 520] ∪ [675, 780] ∪ [0, 900] ∪ [1005, 1350]