1    class Number =
2        def (>) @c (rhs : Self) : bool
3        def (<) @c (rhs : Self) : bool
4        def (>=) @c (rhs : Self) : bool
5        def (<=) @c (rhs : Self) : bool
6    
7        is Comparable
8    
9        def min (rhs : Self) = if self <= rhs then self else rhs
10       def max (rhs : Self) = if self >= rhs then self else rhs
11   
12       def clamp (min : Self) (max : Self) =
13           assert min <= max
14           when
15               self < min -> min
16               self > max -> max
17               else -> self
18   
19       def (==) @c (rhs : Self) : bool
20       def (*) @c (rhs : Self) : Self
21       def (/) @c (rhs : Self) : Self
22       def (+) @c (rhs : Self) : Self
23       def (-) (rhs : Self) : Self
24