integer.flow
Library provides integer
opquae type alias for number
and set of functions
to work with integer
type values with guarantees that any integer
returned
is not a floating point number, NaN
or (-
)Infinity
.
API
Import
Integer.integer:number
Library exposes integer
, a subtype of a number
that is guranteed to not be a floating point number, NaN
or (-
)Infinity
.
Integer.parseInteger(string):?integer
Try to turn given string into an intgere
, unlike built-in parseInt
this function never returns NaN
or an Infinity
, but rather retuns null
(?
portion of ?integer
). It also unlike built-in parseInt
fails (returns null
) on strings than aren't numbers like "0what?"
.
Integer //> 123Integer //> 1234Integer //> -1234Integer //> 26Integer //> 48879Integer //> nullInteger //> nullInteger //> nullInteger //> nullInteger //> 0Integer // > nullInteger //> nullInteger //> nullInteger //> nullInteger //> nullInteger //> null
Integer.div(integer, integer):integer
Integer division. The remainder is discarded.
Integer.rem(integer, integer):integer
Find the remainder after dividing one number by another.
Integer //> 3Integer //> 0Integer //> 1Integer //> -1
Integer.mod(integer, integer):integer
Perform modular arithmetic.
Integer //> 1Integer //> 3
Integer.round(number):integer
Round a number to the nearest integer.
Integer.floor(number):integer
Floor function, rounding down.
Integer.ceiling(number):integer
Ceiling function, rounding up.
Integer.truncate(number):integer
Truncate a number, rounding towards zero.
Install
npm install integer.flow