ToInteger64 (open)

Returns an integer64 representation of a string


LOADLIB "wh::system.whlib";

INTEGER64 FUNCTION ToInteger64(STRING str, INTEGER64 defaultvalue, INTEGER radix)



String to convert

INTEGER64 defaultvalue

Value to return if 'str' is not a valid number in the specified number system


Number system used in the string, ranging from 2 to 36. If the base is out of range, defaultvalue is returned. This parameter is optional and defaults to 10 (decimal system)

Return value


The number in the passed string as an integer64, or defaultvalue if the conversion failed.


ToInteger64 parses the string, and attempts to return an integer of the specified base (radix). If the function failed to parse the specified string, it will return @italic defaultvalue

A base of 10 indicates that a decimal number should be converted, 8 octal, 16 hexadecimal, and so on.


// The following examples all return 15
INTEGER64 example1 := ToInteger64("15", -1);
INTEGER64 example2 := ToInteger64("15", -1, 10);
INTEGER64 example3 := ToInteger64("F", -1, 16);
INTEGER64 example4 := ToInteger64("1111", -1, 2);

// The following faulty strings all return -1
INTEGER64 example5 := ToInteger64("15,99", -1);
INTEGER64 example6 := ToInteger64("5*3", -1, 10);
INTEGER64 example7 := ToInteger64("FFFFFFFFFFFFFFFFF", -1, 16);
INTEGER64 example8 := ToInteger64("22", -1, 2);