ConvertToText('Expression','IntegerDigits*=1','FractionalDigits*='',PlusSign*=2','DecimalSeparator*=0','Base*=10')
Arguments
|
'Expression' |
Expression (floating point value), which should be converted into text |
|
|
'IntegerDigits*' |
Minimum number of integer digits |
|
|
'FractionalDigits*' |
Number of decimal digits |
|
|
'PlusSign*' |
Representation of positive values (plus sign) |
|
|
'PlusSign' = 0 'PlusSign' = 1 'PlusSign' = 2 'PlusSign' = 3 |
Space "+" Nothing Prefix for numbers with other bases than 10: 0x for hexadecimal numbers 0b for binary numbers 0o for octal numbers |
|
|
'DecimalSeparator*' |
Decimal point |
|
|
'DecimalSeparator*'= 0 'DecimalSeparator*'= 1 |
Dot Comma |
|
|
'Base*' |
Numerical base of the resulting number |
|
|
'Base=2' 'Base=8' 'Base=10' (default) 'Base=16' |
binary octal decimal hexadecimal |
|
Parameters ending with * are only evaluated once at the start of the acquisition.
Description
This function returns a floating-point value as text. You can specify the minimum number of integer digits with the argument 'IntegerDigits'. By means of the argument 'FractionalDigits' you specify the number of decimal digits. If 'FractionalDigits' is smaller than zero, then only non-zero digits will be printed. If 'FractionalDigits' is larger than zero, then zeros are printed. The parameter 'PlusSign' determines the printing of the plus sign.
The 'Base' argument determines the numerical base which should be used for the representation of the converted number in the text. You can choose between the values 2 (binary), 8 (octal), 10 (decimal, default) or 16 (hexadecimal).
If the 'Base' argument has a different value than 10, it has an effect on other arguments:
-
The 'IntegerDigits' argument determines the exact number of digits instead of the minimal number of digits like for decimal values.
-
The 'FractionalDigits' and 'DecimalSeparator' arguments are ignored entirely. The behavior here is to round the number and therefore remove the fractional part.
You may use the 'PlusSign' argument to add a prefix to the resulting number, corresponding to its numerical base, e.g. "0x" for hexadecimal values.
Note |
|
|---|---|
|
When converting negative numbers to text, two’s complement representation is used. This uses 64 bits of precision, so the resulting strings become very large. To limit the length of the string, the 'IntegerDigits' argument is used. It is important to note, that excess digits are simply cut off. |
|
Example 1: Conversion of a floating-point value to text
Examples for the floating-point value [FloatValue] = 42.471130 with different argument settings
The 'Base' argument is not mentioned because the base is 10, which is the default value.
|
'Expression' |
'Expression' |
'IntegerDigits' |
'FractionalDigits' |
'PlusSign' |
'DecimalPoint' |
|
[FloatValue] Value: 42.471130 |
1 |
4 |
2 |
1 |
|
|
Formula |
|
||||
|
Result |
42.4711 |
||||
|
'Expression' |
'Expression' |
'IntegerDigits' |
'FractionalDigits' |
'PlusSign' |
'DecimalPoint' |
|
[FloatValue] Value: 42.471130 |
1 |
6 |
1 |
1 |
|
|
Formula |
|
||||
|
Result |
+42.471130 |
||||
|
'Expression' |
'Expression' |
'IntegerDigits' |
'FractionalDigits' |
'PlusSign' |
'DecimalPoint' |
|
[FloatValue] Value: 42.471130 |
1 |
-6 |
0 |
1 |
|
|
Formula |
|
||||
|
Result |
42.47113 |
||||
Example 2 Conversion of decimal values to text with consideration of the numerical base
The 'PlusSign' argument is set to 3 in order to indicate the numerical base of the resulting number by a prefix.
Base 2 (binary)
|
Formula |
|
|||||
|
[DecimalValue] |
'IntegerDigits' |
'FractionalDigits' |
'PlusSign' |
'DecimalSeparator' |
'Base' |
Result |
|
9.00 |
8 |
-2 |
3 |
1 |
2 |
0b00001001 |
|
16.00 |
8 |
-2 |
3 |
1 |
2 |
0b00010000 |
|
255 |
8 |
-2 |
3 |
1 |
2 |
0b11111111 |
Base 8 (octal)
|
Formula |
|
|||||
|
[DecimalValue] |
'IntegerDigits' |
'FractionalDigits' |
'PlusSign' |
'DecimalSeparator' |
'Base' |
Result |
|
9.00 |
6 |
-2 |
3 |
1 |
8 |
0o000011 |
|
16.00 |
6 |
-2 |
3 |
1 |
8 |
0o000020 |
|
255 |
6 |
-2 |
3 |
1 |
8 |
0o000377 |
Base 16 (hexadecimal)
|
Formula |
|
|||||
|
[DecimalValue] |
'IntegerDigits' |
'FractionalDigits' |
'PlusSign' |
'DecimalSeparator' |
'Base' |
Result |
|
9.00 |
4 |
-2 |
3 |
1 |
16 |
0x0009 |
|
16.00 |
4 |
-2 |
3 |
1 |
16 |
0x0010 |
|
25.00 |
4 |
-2 |
3 |
1 |
16 |
0x00FF |