2022-08-04 17:38:00 +12:00
|
|
|
```doc
|
|
|
|
# Integer
|
|
|
|
|
|
|
|
This protocol defines all the protocols required for a value to masquerade as an integer.
|
|
|
|
|
|
|
|
For the concrete implementation see `Outrun.Core.Integer`.
|
|
|
|
```
|
|
|
|
protocol Integer,
|
|
|
|
requires:
|
|
|
|
Addition + BitwiseAnd + BitwiseOr + BitwiseXor + Division + Equality +
|
|
|
|
Exponentiation + GreaterOrEqual + Greater + LessOrEqual + Less + Modulus +
|
|
|
|
Multiplication + ShiftLeft + ShiftRight + Subtraction,
|
2022-08-07 16:20:33 +12:00
|
|
|
as: do
|
2022-08-04 17:38:00 +12:00
|
|
|
|
|
|
|
```doc
|
|
|
|
Computes the absolute value of `self`.
|
|
|
|
```
|
|
|
|
def abs(self: Self): Option
|
|
|
|
|
|
|
|
```doc
|
|
|
|
Returns whether the value of `self` is greater than zero.
|
|
|
|
```
|
|
|
|
def positive?(self: Self): Boolean
|
|
|
|
|
|
|
|
```doc
|
|
|
|
Returns whether the value of `self` is zero.
|
|
|
|
```
|
|
|
|
def zero?(self: Self): Boolean
|
|
|
|
|
|
|
|
```doc
|
|
|
|
Returns whether the value of `self` is less than zero.
|
|
|
|
```
|
|
|
|
def negative?(self: Self): Boolean
|
|
|
|
end
|