|
|
|
|
- Detailed format of the character string to obtain
- Limits
- Conversion into bytes
NumToString (Function) In french: NumériqueVersChaîne Transforms a numeric value (integer, real or currency) into a character string according to the specified format.
NumToString(123) // Returns "123" NumToString(1.23) // Returns "1.23" NumToString(12345.5, "+10.2f") // Returns " +12345.50" NumToString(12345.5, "-+10.2f") // Returns "+12345.50 " NumToString(12345.5, "+010.2f") // Returns "+012345.50" NumToString(12345.5, "010.2f") // Returns "0012345.50"
NumToString(12345.5, "10.2fS") // Returns " 12 345.50" (the thousand separator is " ")
NumToString(12345.5, "10,2fS") // Returns " 12 345,50" (the decimal separator is ",")
Syntax
<Result> = NumToString(<Number> [, <Format>])
<Result>: Character string Number expressed in character string format according to the selected format. If <Number> is a string, this string is returned as it is. The format is ignored. <Number>: Integer or real Numeric value to convert into a character string (according to the specified format). <Format>: Optional character string or constant Remarks Detailed format of the character string to obtain To convert a numeric value into a string, you need to specify the format of the string you want to get. This format is described as follows:
"[<Alignment>][<Sign>][<Zero>][<Size>][<.Precision>]<Type>[<Thousand>]"
The possible values are as follows: | | <Alignment> | If this parameter is specified, justifies the number to the left (<Alignment> = "-"). The number is justified to the right by default. | <Sign> | If this parameter is specified, forces the sign for the positive numbers (<Sign> = "+"). This sign will appear on the left of the first significant number. By default, only the negative numbers have a "-" sign on the left of the first significant number. Special case: if this parameter is specified and if the number is equal to 0, the "+" sign will be displayed. Same if a negative number becomes equal to 0. | <Zero> | If this parameter is specified (<Zero> ="0"), the number will be completed with zero on the left of the first significant number if the significant part of the number is smaller that the requested size and the number is right justified. By default, the number is not filled with "0". For example: NumToString(123, "05d") will return "00123". | <Size> | Defines the total length of the result string. The total length corresponds to the following elements: sign, thousand separator, decimal point, exponent, integer and decimal parts of the number. This size must be less than 100. If the specified size is too small to contain the significant part of the number, it will be ignored. By default, the number will have the size of its significant part (it cannot be filled with zeros). Same if <Size> = 0. If the specified size is greater than the significant part of the number:- the result string will be filled with space characters on the right if the number is justified to the left,
- the result string will be filled with space characters or zeros on the left if the number is justified to the right.
| <.Precision> | Defines the decimal separator ("." or "," characters) and the number of decimal places (for the float ("f") and exponent ("e") <Types> only). The decimal separator: - If the decimal separator is a comma, the decimal separator will be the one defined:
- in the linguistic parameters of Windows.
- in the Windows configuration of the server.
- for the current user.
- If the decimal separator is a dot, the decimal separator used will be a dot.
Notes: - ChangeSeparator has no effect on this separator. Indeed, this function acts on the display mask of numeric values in the controls.
- The <,Precision> syntax cannot be used: you must use <.Precision>.
Number of decimals: - The number of decimal places must be less than 100.
- If the number of decimal places in the number is greater than <Precision>, the decimal part is rounded to the specified number of decimal places.
- If the number of decimals in the number is less than <Precision>, the decimal part is filled with "0" to the right.
- The value of <Precision> can be greater than <Size>. In this case, <Size> is ignored.
| <Type> | Type of the result, mandatory parameter: - d: Integer:
A real number will be rounded to the nearest integer. - e: Exponential notation:
If <Precision> is not indicated, 6 digits by default. - f: Decimal notation:
If <Precision> is not indicated, 6 digits by default. - x and X: Hexadecimal notation (X for uppercase letters):
Only the integer part of the number is taken into account (no rounding). Special case: 1. Size not specified and negative number: 20 hexadecimal characters for a currency, 8 characters for all the other numeric types. 2. Negative number: the size of the result string will be at least the size allowing to specify the sign bit. For example: -32767 if the "3X" format will return "8001" - o: Octal notation:
Only the integer part of the number is taken into account (no rounding). Special case: 1. Size not specified and negative number: 27 hexadecimal characters for a currency, 11 characters for all the other numeric types. 2. Negative number: the size of the result string will be at least the size allowing to specify the sign bit. For example: -32767 in the "3o" format will return "700001"
| <Thousand> | Thousand separator (<Thousand> = "S" or "s"). The digits found in the integer part of the number will be grouped by 3 and separated by the thousands separator defined in Windows. If the sign is present, it will always be displayed immediately to the left of the first significant digit. No thousands separator can be found between the sign and the first digit.
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|