Product Documentation
Virtuoso Visualization and Analysis XL SKILL Reference
Product Version IC23.1, November 2023

numConv

numConv(
t_inputNumber
t_format
g_needPrefix
)
=> t_outputNumber / nil

Description

Converts an input number to the specified format.

Arguments

t_inputNumber

The number to be converted into the specified format.

You must specify the number in a string format.

t_format

Format in which you want to convert the specified number.

Valid values are:

  • bin: Converts the number into binary format.
  • dec: Converts the number into decimal format.
  • hex: Converts the number into hexadecimal format.
  • oct: Converts the number into octal format.
  • sdec: Converts the number into signed decimal format.
  • udec: Converts the number into unsigned decimal format.

g_needPrefix

Specifies whether to add a prefix to the output number to indicate its format.

Valid values are:

  • t: A prefix is added to the output. The prefix depends on the specified format in which you want to convert the input number. For example, prefix 0 is added to the output if the specified format is octal. Prefix 0b indicates that the output format is binary. Prefix 0x indicates that the output format is hexadecimal.
  • nil: Prefix is not added to the output.

Value Returned

t_outputNumber

Output number converted in the specified format. The output value is returned in the string format.

nil

Number cannot be converted because of an error.

Examples

The following example converts an input number 100 into hexadecimal format. Note that a prefix 0x is added to the output because the argument g_needPrefix is set to t.

numConv("100" "hex" t)
=> "0x64"

The following example converts an input number 100 into hexadecimal format. Note that no prefix is added to the output because the argument g_needPrefix is set to nil.

numConv("100" "hex" nil)
=> "64"

The following example converts an input number 100 into binary format. Note that a prefix 0b is added to the output because the argument g_needPrefix is set to t.

numConv("100" "bin" t)
=> "0b1100100"

The following example converts an input number 100 into binary format. Note that no prefix is added to the output because the argument g_needPrefix is set to nil.

numConv("100" "bin" nil)
=> "1100100"

Return to top
 ⠀
X