2022-08-19 16:25:42 +12:00
|
|
|
use AbsoluteValue
|
|
|
|
use Addition
|
|
|
|
use Boolean
|
|
|
|
use Division
|
|
|
|
use Equality
|
|
|
|
use Greater
|
|
|
|
use GreaterOrEqual
|
|
|
|
use Less
|
|
|
|
use LessOrEqual
|
|
|
|
use Multiplication
|
|
|
|
use Negation
|
|
|
|
|
2022-08-09 12:39:52 +12:00
|
|
|
```doc
|
|
|
|
# Float
|
|
|
|
|
|
|
|
This protocol defines all the protocols and functions required for a value to masquerade as a floating point number.
|
|
|
|
```
|
|
|
|
protocol Float,
|
|
|
|
requires:
|
|
|
|
AbsoluteValue + Addition + Division + Equality + Greater + GreaterOrEqual +
|
|
|
|
Less + LessOrEqual + Multiplication + Negation,
|
|
|
|
as: do
|
|
|
|
def nan?(self: Self): Boolean
|
|
|
|
def infinite?(self: Self): Boolean
|
|
|
|
def finite?(self: Self): Boolean
|
|
|
|
def subnormal?(self: Self): Boolean
|
|
|
|
def normal?(self: Self): Boolean
|
|
|
|
def sign_positive?(self: Self): Boolean
|
|
|
|
def sign_negative?(self: Self): Boolean
|
|
|
|
def inverse(self: Self): Option
|
|
|
|
end
|