ish.type.int

Integer-based type functionality.

Source:

Methods

ish.type.int.is(x) → {boolean}

Source:
Determines if the passed value represents an integer (includes implicit casting per the Javascript rules, see: {@link: ish.type.int.mk}).
Parameters:
Name Type Description
x variant Value to interrogate.
Returns:
Type Description
boolean Value representing if the passed value represents an integer.

ish.type.int.mk(x, vDefaultValopt, iRadixopt) → {integer}

Source:
Casts the passed value into an integer (includes implicit casting per the Javascript rules, see below).
Example

Javascript has some funky rules when it comes to casting numeric values, and they are at play in this function.
In short, the first non-whitespace numeric characters are used in the cast, until any non-numeric character is hit.

    "12 monkeys!" === 12;
    "   12 monkeys!" === 12;
    "12monkeys!" === 12;
    "1.2 monkeys!" === 1.2;
    "1,2 monkeys!" === 1; // (not 1.2, sorry Europe)
    "1 2 monkeys!" === 1; // (not 12)
    "1,200 monkeys!" === 1; // (not 1200)
    "11 - there were 12 monkeys!" === 11;
    "twelve (12) monkeys!" === undefined;
    "$12 monkeys!" === undefined;
Parameters:
Name Type Attributes Default Description
x variant Value to interrogate.
vDefaultVal variant <optional>
0 Value representing the default return value if casting fails.
iRadix integer <optional>
10 Value between 2-36 that represents the radix (the base in mathematical numeral systems) passed into parseInt.
Returns:
Type Description
integer Value representing the passed value as an integer type.