Display Formats for Numeric and Float Data
Display formats for numeric data typically apply a pattern to the data. For example, you can define the number of digits before or after the decimal point, put a currency symbol in front (or behind the value), or define whether the decimal and thousand separators should be commas or periods.
Note: Dynamic server pages support a subset of the display formats that can be used in forms, and have other formatting limitations. For more information, see Display Formats for Numeric and Float Data in Dynamic Server Pages.
You can set the NLS locale using the
$NLS_LOCALE
assignment setting or $nlslocale ProcScript function to a
specific locale. This is used in desktop and server-based applications, and in server-side processing of dynamic server pages (DSPs).
You can override the behavior specified by NLS locale by setting
$NLS_FORMAT
or $nlsformat. For example, if $NLS_LOCALE
is set
to en_gb
, that is English(United Kingdom), and you do not want the formatting of
numeric and floating point fields to be affected by the locale, you can set
$NLS_FORMAT
to classic
.
If $NLS_FORMAT
(or $nlsformat) is
set to nlslocale
, and $NLS_LOCALE
(or
$nlslocale) specifies a locale (language and country) or
system
, the standard display formats are treated as $NLS(
FormatPattern)
. This will affect the decimal separator, thousand separator, and currency symbol.
In dynamic server pages, these settings have no effect. Instead, you can use $webinfo("locale") to define the locale used for client-side formatting.
$NLS Display Formats for Numeric and Float
Setting NLS display formats applies the conventions regarding plus, minus, digits, decimal separator, thousand separator, and currency symbol that are applicable to the current locale.
$NLS(NUMERIC)
Use the decimal and thousand separators appropriate to the locale.
Locale | User Input | Internal Value | Result |
---|---|---|---|
English (United States) | 123456789.123
|
123456789.123
|
123,456,789.123
|
Dutch (Netherlands) | 123456789,123
|
123456789.123
|
123.456.789,123
|
French (Canada) | 123456789,123
|
123456789.123
|
123 456 789,123
|
$NLS(FLOAT)
Displays the decimal separator appropriate to the locale.
Locale | User Input | Input | Result |
---|---|---|---|
English (United States) | 1234567.89
|
1234567.89
|
1.234567891234E8
|
Dutch (Netherlands) | 1234567,89
|
1234567.89
|
1,234567891234E8
|
French (Canada) | 1234567,89
|
1234567.89
|
1,234567891234E8
|
$NLS(CURRENCY)
Display the currency symbol, before or after the data, depending on the locale. (Not supported in dynamic server pages.)
Input | Locale | Result |
---|---|---|
1234567.89
|
English (United States) | $ 123,456,789.12
|
Dutch (Netherlands) | € 1.234.567,89
|
|
French (Canada) | 1 234 567,89 $
|
$NLS(FormatPattern)
Use a Numeric or Float display format but apply thousand and decimal separators according to the locale.
Locale | User Input | Input | Result |
---|---|---|---|
English (United States) | 1234567.89
|
1234567.89
|
1,234,567.89
|
Dutch (Netherlands) | 1234567,89
|
1234567.89
|
1.234.567,89
|
French (Canada) | 1234567,89
|
1234567.89
|
1 234 567,89
|
Codes for Numeric Display Formats
The standard Uniface display formats explicitly apply a pattern of digits (with or without leading and trailing zeros), plus and minus signs, decimal location, separators.
For dynamic server pages, only the display format characters 9
, z
, P
, and K
are supported.
If a display format pattern consists of illegal characters (for example DIS(XXXX)
), or it contains legal characters that are combined into an invalid display format (such as DIS(B.)
), a compiler warning is issued, the display format is ignored, and the scaling defined by the database interface is applied.
Database Interface | Display Format | Input Value | Formatted Value |
---|---|---|---|
I8.4 | DIS(XXXX)
|
1234.123456
|
compiler warning 1136 |
I8.4 | DIS(B.)
|
1234.123456
|
compiler warning 1136 |
9
: Digit or leading/trailing zero
Input Value | Formatted Value |
---|---|
00123
|
00123
|
123
|
123
|
12345
|
12345
|
123456
|
error: "too much data" |
-123
|
error: "illegal numeric" |
123.45
|
12345 (no point defined)
|
z
: Digit; leading and trailing zeros are suppressed
Input Value | Formatted Value |
---|---|
00123
|
123
|
|
123
|
12345
|
12345
|
123.45
|
12345
|
123456
|
error: too much data |
-1234
|
error: illegal numeric |
+
: Plus sign for positive values (>0)
If the input value is positive, the plus sign is positioned as specified by the display format.
Input Value | Formatted Value |
---|---|
123
|
+123
|
-123
|
123
|
Input Value | Formatted Value |
---|---|
123
|
123+
|
-123
|
123
|
-
: Minus sign for negative values (<0) [Forms only]
If the input value is negative, the minus sign is positioned as specified by the display format.
Input Value | Formatted Value |
---|---|
123
|
123
|
-123
|
-123
|
Input Value | Formatted Value |
---|---|
123
|
123
|
-123
|
123-
|
B
: Spaces for suppressed zeros, minus (-)
and plus (+) signs
Input Value | Formatted Value |
---|---|
123
|
123
|
01234
|
1234 |
Input Value | Formatted Value |
---|---|
123
|
123
|
-123
|
- 123
|
Input Value | Formatted Value |
---|---|
-123
|
- 123
|
1234
|
1234
|
Input Value | Formatted Value |
---|---|
-123 | -123 |
1234 | 1234 |
P
: Fixed decimal point
Input Value | Formatted Value |
---|---|
123
|
123.00 |
123.45
|
123.45
|
12.3
|
012.30
|
1234.5
|
error: too much data |
123.456
|
error: too much data |
Input Value | Formatted Value |
---|---|
123
|
123.0
|
.8970
|
0.897
|
012.120
|
12.12
|
K
: Fixed decimal comma
Input Value | Formatted Value |
---|---|
123
|
123,00
|
123.45
|
123,45
|
12.3
|
012,30
|
1234.5
|
error: too much data |
123.456
|
error: too much data |
Input Value | Formatted Value |
---|---|
123
|
123,0
|
.8970
|
0,897
|
012.120
|
12,12
|
.
(Point): Layout decimal point
Input Value | Formatted Value |
---|---|
12345678
|
123.45.678
|
12345
|
12.345
|
1.234
|
1.234
|
123.45.67
|
123.45.67 |
,
(Comma): Layout decimal comma
Input Value | Formatted Value |
---|---|
12345678
|
123,45,678
|
12345
|
12,345
|
1,234
|
1,234
|
123,45,67
|
123,45,67
|
$
: Dollar sign
If defined in
$NLS(
Pattern)
, the $
is replaced by the locale currency
symbol.
Input Value | Formatted Value |
---|---|
1234567.89
|
$ 1,234,568.0
|
w {.
d}e
The value in w number of characters, in exponential notation, such that it appears as follows:
- If Value< 0, a
leading minus sign (
-
) indicating the sign of the value. - One digit to the left of the decimal point.
- Decimal point (
.
) - Maximum of w
digits to the right of the decimal point, if both w and the available precision
allow. (If w is
0
or omitted, all the available characters are used to display as many of the digits of precision as possible.) e
- Plus sign (
+
) or minus sign (-
), indicating the sign of the exponent (power of 10) - The exponent (in at least two and up to four digits). To allow space for the extra characters, the width, w, should be at least d+7.
Input Value | Formatted Value |
---|---|
123.45 | 1.23450e+02 |
-123.45 | -1.23450e+02 |
.9876 | 9.87600e-01 |
123456789 | 1.234567e+08 |
123.45 | 1.23450e+02 |
Input Value | Formatted Value |
---|---|
123.45 | 1.235e+02 |
-123.45 | -1.23e+02 |
Input Value | Formatted Value |
---|---|
123.45 | 1.234500e+02 |
-123.45 | -1.23450e+02 |
.9876 | 9.876000e-01 |