Numbers.toNumber()

Convert the given input string to a number.

This machine specifically converts "numeric" strings (e.g. "123", "-5", "4.56" and "1.23e+50") to numbers. If the string is not numeric, an error will be triggered. If you need to convert _any_ string to a number (defaulting to zero) use the "Construct value" machine from the "Util" pack. Note that the strings "Infinity" and "-Infinity" will also trigger an error.

Usage

Hover over inputs/exits for more info.

var Numbers = require('machinepack-numbers');


// Convert the given input string to a number.

Numbers.toNumber({

string: '123',

}).execSync();

Inputs

string

The string to convert to a number.

'123'

Exits

error

An unexpected error occurred.

success

OK.

123