outrun/outrun-core/lib/integer.outrun

49 lines
1.1 KiB
Text
Raw Normal View History

2022-08-19 16:25:42 +12:00
use AbsoluteValue
use Addition
use BitwiseAnd
use BitwiseOr
use BitwiseXor
use Boolean
use Division
use Equality
use Exponentiation
use GreaterOrEqual
use Greater
use LessOrEqual
use Less
use Modulus
use Multiplication
use Negation
use ShiftLeft
use ShiftRight
use Subtraction
2022-08-04 17:38:00 +12:00
```doc
# Integer
2022-08-09 12:39:52 +12:00
This protocol defines all the protocols and functions required for a value to masquerade as an integer.
2022-08-04 17:38:00 +12:00
For the concrete implementation see `Outrun.Core.Integer`.
```
protocol Integer,
requires:
2022-08-09 12:39:52 +12:00
AbsoluteValue + Addition + BitwiseAnd + BitwiseOr + BitwiseXor + Division +
Equality + Exponentiation + GreaterOrEqual + Greater + LessOrEqual + Less +
Modulus + Multiplication + Negation + ShiftLeft + ShiftRight + Subtraction,
as: do
2022-08-04 17:38:00 +12:00
```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