Updated: January 26, 2017

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:

  • You need to display numbers based on the user’s locale settings.

Do not use number formatting if:

  • You need to display IDs.
  • You need to display telephone numbers.

Types

You can use three different datatypes for numbers: integerfloat, 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).

Number to format: 1000000000000

United States (US): 1T

Germany (DE): 1 Bio.

China (CN): 1兆

Switzerland (CH): 1 Bio.

Number to format: 1000000000

United States (US): 1B

Germany (DE): 1 Mrd.

China (CN): 10亿

Switzerland (CH): 1 Mrd.

Number to format: 1000000

United States (US): 1M

Germany (DE): 1 Mio.

China (CN): 100万

Switzerland (CH): 1 Mio.

Number to format: 1000

United States (US): 1K

Germany (DE): 1 Tsd.

China (CN): 1,000

Switzerland (CH): 1 Tsd.

Standard

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

Number to format: 10000000

United States (US): 10,000,000

Germany (DE): 10.000.000

China (CN): 10,000,000

Switzerland (CH): 10’000’000

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.

Number to format: 1000000000000

United States (US): 1 trillion

Germany (DE): 1 Billion

China (CN): 1兆

Switzerland (CH): 1 Billion

Number to format: 1000000000

United States (US): 1 billion

Germany (DE): 1 Milliarde

China (CN): 10亿

Switzerland (CH): 1 Milliarde

Number to format: 1000000

United States (US): 1 million

Germany (DE): 1 Million

China (CN): 100万

Switzerland (CH): 1 Million

Number to format: 1000

United States (US): 1 thousand

Germany (DE): 1 Tausend

China (CN): 1,000

Switzerland (CH): 1 Tausend

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.

Number to format: 1590000000000

United States (US): 15.9T

Germany (DE): 1,59 Bio.

China (CN): 1.59兆

Switzerland (CH): 1.59 Bio.

Number to format: 15900000000

United States (US): 15.90B

Germany (DE): 15,90 Mrd.

China (CN): 159.00亿

Switzerland (CH): 15.90 Mrd.

Number to format: 1590000

United States (US): 1.59M

Germany (DE): 1,59 Mio.

China (CN): 159.00万

Switzerland (CH): 1.59 Mio.

Number to format: 1590

United States (US): 1.59K

Germany (DE): 1,59 Tsd.

China (CN): 1,590.00

Switzerland (CH): 1.59 Tsd.

Standard

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

Number to format: 15900000

United States (US): 15,900,000.00

Germany (DE): 15.900.000,00

China (CN): 15,900,000.00

Switzerland (CH): 15’900’000.00

Long

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

Number to format: 1590000000000

United States (US): 1.59 trillion

Germany (DE): 1,59 Billionen

China (CN): 1.59兆

Switzerland (CH): 1.59 Billionen

Number to format: 1590000000

United States (US): 1.59 billion

Germany (DE): 1,59 Milliarden

China (CN): 15.90亿

Switzerland (CH): 1.59 Milliarden

Number to format: 1590000

United States (US): 1.59 million

Germany (DE): 1,59 Millionen

China (CN): 159.00万

Switzerland (CH): 1.59 Millionen

Number to format: 1590

United States (US): 1.59 thousand

Germany (DE): 1,59 Tausend

China (CN): 1,590.00

Switzerland (CH): 1.59 Tausend

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.

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Short format                   TND 150مليو

Standard format             TND 150,000,000.990

Long format                    TND 150 مليون

Short

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

Number to format: 15000000000000.99

United States (US): EUR 15.00T

Germany (DE): 15,00 Bio. EUR

China (CN): EUR 15.00兆

Switzerland (CH): 15.00 Bio. EUR

Tunisia (TN): EUR 15.00 تريليون

Number to format: 15000000000.99

United States (US): EUR 15.00B

Germany (DE): 15,00 Mrd. EUR

China (CN): EUR 150.00亿

Switzerland (CH): 15.00 Mrd. EUR

Tunisia (TN): EUR 15.00 مليار

Number to format: 15000000.99

United States (US): EUR 15.00M

Germany (DE): 15,00 Mio. EUR

China (CN): EUR 1,500.00万

Switzerland (CH): 15.00 Mio. EUR

Tunisia (TN): EUR 15.00 مليون

Number to format: 15000.99

United States (US): EUR 15.00K

Germany (DE): 15,00 Tsd. EUR

China (CN): EUR 1.50万

Switzerland (CH): 15.00 Tsd. EUR

Tunisia (TN): EUR 15.00 ألف

Standard

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

Number to format: 15000000.99

United States (US): EUR 15,000,000.99

Germany (DE): 15.000.000,99 EUR

China (CN): EUR 15,000,000.99

Switzerland (CH): 15’000’000.99 EUR

Tunisia (TN): EUR 15,000,000.99

Long

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

Number to format: 15000000.99

United States (US): EUR 15.00 million

Germany (DE): 15,00 Millionen EUR

China (CN): EUR 1,500.00万

Switzerland (CH): 15.00 Millionen EUR

Tunisia (TN): EUR 15.00 مليون

Number to format: 15000000000.99

United States (US): EUR 15.00 billion

Germany (DE): 15,00 Milliarden EUR

China (CN): EUR 150.00亿

Switzerland (CH): 15.00 Milliarden EUR

Tunisia (TN): EUR 15.00 مليار

Number to format: 15000000000000.99

United States (US): EUR 15.00 trillion

Germany (DE): 15,00 Billionen EUR

China (CN): EUR 15.00兆

Switzerland (CH): 15.00 Billionen EUR

Tunisia (TN): EUR 15.00 تريليون

Number to format: 15000.99

United States (US): EUR 15.00 thousand

Germany (DE): 15,00 Tausend EUR

China (CN): EUR 1.50万

Switzerland (CH): 15.00 Tausend EUR

Tunisia (TN): EUR 15.00 ألف

Guidelines

  • In general, use the standard format.
  • Follow the rules of the corresponding control to format the data appropriately. (For example, show 1.7M instead of 1,700,000 in the object list item.)
  • Use float numbers to prevent truncation of decimal places.
  • If you need to display amount fields without a value, leave them blank. Do not display a text as N/A.
  • Always use the correct format according to your language or locale setting to prevent confusion caused by incorrect formatting. (For example, “200,000” is interpreted as “two hundred thousand” in the United States, but “two hundred point zero” in Germany.)
  • If you need to display decimal numbers, use float and keep the number of digits after the decimal point to a minimum.
  • Use object numbers where possible, for example, to display amounts in forms and responsive tables.

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