ToNumeric

Cast a value to a number.

Method Signature

ToNumeric(value=[string], radix=[any])

Arguments

Argument
Type
Required
Description
Default

value

string

true

The value to cast.

radix

any

false

The radix to use when casting the value. Valid values are 2-36, "bin", "oct", "dec", and "hex".

Examples

Cast a string to a number.

Run Example

toNumeric( "29.5" );

Result: 29.5

Cast a hex-value to a number.

Run Example

toNumeric( "FF0011", "hex" );

Result: 16711697

Cast a binary-value to a number.

Run Example

toNumeric( "1010", "bin" );

Result: 10

Additional Examples

Run Example

writeDump( toNumeric( "123.45" ) );
writeDump( toNumeric( "0110", "bin" ) ); // 6
writeDump( toNumeric( "000C", "hex" ) ); // 12
writeDump( toNumeric( "24", "oct" ) );
 // 30

Last updated

Was this helpful?