Function number

Create a number or convert a string, boolean, or unit to a number. When value is a matrix, all elements will be converted to number.


number(unit, valuelessUnit)


Parameter Type Description
value string | number | BigNumber | Fraction | boolean | Array | Matrix | Unit | null Value to be converted
valuelessUnit Unit | string A valueless unit, used to convert a unit to a number


Type Description
number | Array | Matrix The created number


number(2);                         // returns number 2
number('7.2');                     // returns number 7.2
number(true);                      // returns number 1
number([true, false, true, true]); // returns [1, 0, 1, 1]
number(unit('52cm'), 'm');    // returns 0.52

See also

bignumber, boolean, complex, matrix, string, unit