Formatting Numbers

sap.ui.core.format.NumberFormat

Intro

This article describes the international rules for number formats. The SAPUI5 number formatters will help you to comply with these rules.

Usage

Use number formatting if:

Do not use number formatting if:

Types

You can use three different datatypes for numbers: integer, float, and currency. Each datatype can be formatted using a short, standard, or long format.

Integer

Use integer if no decimal places are required.

Short

Integer numbers formatted using the short form are truncated after three digits. When you use the short form, the units are shown as an abbreviation, such as K (thousand), M (million), B (billion), and T (trillion).

Standard

In general, use standard format. When you use standard format, integer numbers are displayed in full.

Formatting numbers - Standard

Formatting numbers - Standard

Long

Integer numbers formatted using the long form are truncated after three digits. The units are shown as full text, such as thousand, million, and so on.

Integer (long)

Float

If you want to show decimal places, use float. The decimal places beyond the defined number of digits are truncated. If the minimum number of decimal digits is not restricted, only the trailing zeros are truncated, which could lead to very large numbers.

Short

Float numbers using the short form are displayed entirely without truncation of the trailing zeros. The units are displayed as an abbreviation, such as K (thousands), M (million), and so on.

Float number - Short

Standard

In general, use the standard format. Numbers using the standard format are displayed in full.

Float number - Standard

Float number - Standard

Long

Use the long format to show units as full text, such as thousand, million, and so on.

Float number - Long

Currency

If you want to show currencies, use the currency formatter. Most currencies have two decimal places, although some need three digits after the decimal point, such as the Tunisian dinar. The currency formatter takes this into account. Currency amounts are rounded down automatically.

Example of Tunisian dinar with three decimal places

Example of Tunisian dinar with three decimal places

Short

Currency amounts that are greater than 1,000 and use the short format are abbreviated.

Currency - Short

Standard

In general, use the standard format. Numbers using the standard format are displayed in full, including the decimal places.

Example of a formatted currency amount - Standard

Example of a formatted currency amount - Standard

Long

Use the long format to show units as full text, such as thousand, million, and so on.

Currency (long)

Guidelines

Resources

Want to dive deeper? Follow the links below to find out more about related controls, the SAPUI5 implementation, and the visual design.

Elements and Controls

Implementation

Visual Design

  • No links