Maptitude GISDK Help |
Formats a number.
formatted_number = Format(real x, string format)
Argument |
Contents |
x |
The number that is formatted |
format |
The format in which the number is represented |
A string containing a formatted version of x.
The format string and the returned string have three parts:
the part to the left of the decimal,
the part to the right of the decimal, and
the part after the exponent indicator.
Each part is formatted separately according to the following rules:
If part of the format string contains an asterisk (*), the corresponding part of the returned string contains as many digits as are necessary to represent that value.
Otherwise, that part of the returned string contains at least as many digits as there are zeros (0) in that part of the format string, and at most as many digits are there are zeros and number signs (#) in that part of the format string.
Zeros are significant digits and number signs are optional digits.
If the format string contains an E, then x is formatted in scientific notation; otherwise, it is not. The case of the E in the returned string matches the case of the E in the format string.
If the format string does not have any required digits to the right of the decimal, and x is an integer, then the decimal point is omitted from the returned string.
If the format string contains a dollar sign ($), then the returned string begins with a dollar sign.
If the format string contains a comma, then the part of the returned string to the left of the decimal has a comma every three digits. The comma and the period must be separated by an asterisk (*) or at least one zero or number sign.
If the format string contains a percent sign (%), then x is multiplied by 100 before being formatted, and the returned string ends with a percent sign.
If x contains more digits to the right of the decimal than are allowed for in the format string, Format() rounds them.
If x contains more digits to the left of the decimal than are allowed for in the format string, then Format() overflows and returns a string consisting only of number signs (#).
If the format string contains the letter i, then the roles of commas and periods in the output is reversed.
If the format string contains a less-than sign (<), then the returned string begins with the text leading up to the less-than sign.
If the format string contains a greater-than sign (>), then the returned string ends with the text after the greater-than sign.
s1 = Format(1234.567, "$0,000.00") |
// s1 is "$1,234.57" |
s2 = Format(1234.567,"*.00000") |
// s2 is "1234.56700" |
s3 = Format(1234567.89, ",*0.00") |
// s3 is "1,234,567.89" |
s4 = Format(.02, ",*0.00") |
// s4 is "0.02" |
s5 = Format(3, "000") |
// s5 is "003" |
s6 = Format(12345, "000") |
// s6 is "###" |
s7 = Format(1234.567, "i0,000.00") |
// s7 is "1.234,57" |
s8 = Format(1234.567, "Sigma = <*.00E000") |
// s8 is "Sigma = 1.23E+003" |
s9 = Format(1234.567, "i,*0.00> NKR") |
// s9 is "1.234,57 NKR" |
Function |
Summary |
Converts an integer to a string |
|
Converts a real number to a string |
|
Converts a real number to a string |
©2025 Caliper Corporation | www.caliper.com |