ParseNumber

Converts a string to a number in the specified numeral system

Method Signature

ParseNumber(number=[string], locale=[string], radix=[string])

Arguments

Argument
Type
Required
Description
Default

number

string

true

The string to convert to a number.

locale

string

false

The locale to use when parsing the number. If not provided, the system or application-configured locale is used.

radix

string

false

The numeral system to use for conversion (e.g., "bin", "oct", "dec", "hex"). If not provided, the number is parsed as locale-sensitive

Examples

Convert decimal number to binary

Run Example

parseNumber( 1010, "bin" );

Result: 10

Convert decimal number to hex

Run Example

parseNumber( 1010, "hex" );

Result: 4112

Additional Examples

Run Example

number = "1000";
echo( ParseNumber( number, "dec" ) ); // 1000
echo( ParseNumber( number, "bin" ) ); // 8
echo( ParseNumber( number, "oct" ) ); // 512
echo( ParseNumber( number, "hex" ) );
 // 4096

Last updated

Was this helpful?