numbers v0.1.1 Numeric behaviour
Any module that wants to be a Numeric type, and to be able to be called by the functions in Number, should make sure that this behaviour is followed.
Summary
Types
numStruct should be a struct that follows the Numeric behaviour
To be used in your typespecs at any place where a Numeric type can be used
Callbacks
The absolute value of a number
Unary minus. Should return the negation of the number
Creates a new numStruct from the given built-in integer or float
Power function, x^n
Convert the custom Numeric struct to the built-in float datatype
Types
To be used in your typespecs at any place where a Numeric type can be used.
Callbacks
Unary minus. Should return the negation of the number.
Creates a new numStruct from the given built-in integer or float.
In the case of reading a float, it is okay to lose precision.
Power function, x^n.
When this optional function is not provided, Number
will use the ‘Exponentiation by Squaring’
algorithm to calculate the result (which uses log(n) repeated multiplications).
Add it to your data type if it is possible to compute a power using a faster algorithm.
Convert the custom Numeric struct to the built-in float datatype.
It is okay to lose precision during this conversion.