Conversion Functions

Version:
2019.3
Last modified: October 29, 2019

A conversion function converts one data type or format to another data type or format. Use a conversion function to convert numbers to strings or strings to numbers. Conversion functions can be used with String and Number data types.

BinToInts(s): Converts the binary string s to an integer. (Limited to 53 bits.)

Example

BinToInts(101010101) results in 341

CharFromInt(x): Returns the Unicode® character that matches the input number.

Example

CharFromInt(66) returns B (U+0042 ‘Latin Capital Letter B’)

CharFromInt(169) returns © (U+00A9 ‘copyright sign’)

CharFromInt(1071) returns Я (U+042F ‘Cyrillic capital letter YA’)

CharFromInt(127944) returns football icon  (U+1F3C8 ‘American football’)

CharFromInt(0) returns [null] (U+000 ‘Null’) because any integer that cannot be used to represent a character may give a null result.

CharFromInt(55300) returns [null] because any integer that does not currently represent a character will not be rendered by a normal font

CharToInt(S): Returns the number that matches the input Unicode® character.

Example

CharFromInt(B) returns 66 (U+0042 ‘Latin Capital Letter B’)

CharFromInt(©) returns 169 (U+00A9 ‘copyright sign’)

CharFromInt(Я) returns 1071 (U+042F ‘Cyrillic capital letter YA’)

CharFromInt(football icon) returns 127944 (U+1F3C8 ‘American football’)

ConvertFromCodepage(s, codePage): Translates text from a code page to Unicode. See Code Pages.

ConvertToCodepage(s, codePage): Translates text from Unicode® encoding to a specific code page. See Code Pages.

HexToNumber(x): Converts a HEX string to a number. (Limited to 53 bits.)

Example

HexToNumber(dd) converts to the number 221

IntToBin(x): Converts x to a binary string

IntToHex(x): Converts x to a hexadecimal string

ToNumber(x, bIgnoreErrors, keepNulls, decimalSeparator): Converts a string parameter to a number. ToNumber accepts strings that can be interpreted as scientific notation double precision. By default, the period is used as the decimal separator.

Optional Parameters

bIgnoreErrors: 0 or false (default) reports conversion error messages; 1 or true ignores conversion errors.

keepNulls: 0 or false (default) converts non-numeric values (including null) to zero; 1 or true converts non-numeric values to null.

decimalSeparator: "." (default) specifies the period as decimal separator; "," specifies the comma as decimal separator.

Example

ToNumber("878") returns the string 878 as a number.

ToNumber("4.256411411E9") returns the string 4256411411 as a number.

ToNumber("Number", "false") returns 0 with conversion error: TONUMBER: Number lost information in conversion.

ToNumber("Number", 0, 0) returns 0 with conversion error: TONUMBER: Number lost information in conversion.

ToNumber("Number", 1, 0) returns 0 with no conversion error.

ToNumber("Number", 1, 1) returns [Null] and no conversion error.

ToNumber("123456,789", 1, 1, ",") returns 123456.789 as a number.

ToNumber("123.456,789", 1, 1, ",") returns 123 as a number. (This is because conversion stops at the thousands separator, which is not valid for input with the ToNumber function.)

ToString(x, numDec, addThousandsSeparator, decimalSeparator): Converts a numeric parameter to a string using numDecdecimal places. By default, the period is used as the decimal separator.

Optional Parameters

addThousandsSeparator: 0 (default) formats the numeric string without a thousands separator; 1 formats with a thousands separator. By default, the thousands separator is a comma unless "," is specified for decimalSeparator, in which case it is a period.

decimalSeparator: "." (default) specifies the period as decimal separator; "," specifies the comma as decimal separator.

Example

ToString(10, 0) returns 10 as a string.

ToString(10.4, 2) returns 10.40 as a string.

ToString(100.4, 2) returns 100.40 as a string.

ToString(1000.4, 2, 1) returns 1,000.40 as a string.

ToString(123456.789, 3, 1, ",") returns 123.456,789 as a string.

ToString(123456.789, 3, 0, ",") returns 123456,789 as a string.

Was This Helpful?

Need something else? Visit the Alteryx Community or contact support.