numbers v0.1.1 Numbers
Exposes helper functions to perform math on numbers which might be custom data types. This allows Compex Numbers to be built on any kind of numeric class.
Math with custom data types is supported, as long as:
1) One or both of the operands are of the type structModule. The arguments are passed to structModule
as-is:
if structModule
supports addition, subtraction, etc. with one of the numbers being a built-in number (e.g. Integer or Float), then this is also supported by the MathHelper.
2) This structModule
module exposes the arity-2 functions add
, sub
, mul
, div
to do addition, subtraction, multiplication and division, respectively.
3) This structModule
exposes the arity-1 function minus
to negate a number and abs
to change a number to its absolute value.
Note that div
is supposed to be precise division (i.e. no rounding should be performed).