Soluling home   Document home

Abbreviated numbers

Abbreviated numbers

Showing big numbers to a user might have problems. The first one is that they tend to be hard to read, especially when the digits get longer than 5. In addition, a long number takes space that might be limited. To avoid these issues, we can use abbreviated numbers. The following table contains some numbers and their abbreviated versions in English, Finnish, and Japanese:

Number English short English long Finnish short Finnish long Japanese
19 19 19

19

19

19

1000 1K 1 thousand 1 t. 1 tuhat 1000
25000 25K 25 thousand 25 t. 25 tuhatta 2.5万
1 200 000 1.2M 1.2 million 1,2 milj. 1,2 miljoonaa 120万
34 000 000 34M 34 million 34 milj. 34 miljoonaa 3400万
2 000 000 000 2G 2 billion 2 mrd. 2 miljardia 20億

As you can see, the abbreviate rules differ a lot, depending on the language. Some cultures use 1000 as a separator (used in Europe), some cultures use 10 000 (e.g., Japan). Some languages use single-letter abbreviations, and some use longer.

AbbreviatedNumber.Format(form, number): string;

It takes two parameters: form (short or long abbreviation) and number, and returns a string.

Platforms

Hardly any platform contains built-in support for abbreviated numbers. Most platforms require that you use our custom API. The API source code is available in GitHub. The following table shows how various platforms support the ordinal numbers:

Platforms Status APIs Samples
.NET Standard yes <data-dir>\Library\​NET\Number.cs

<data-dir>\Samples\ASP.NET\Number
<data-dir>\Samples\WindowsForms\Number
<data-dir>\Samples\WPF\Number
<data-dir>\Samples\UWP\Number

Android yes <data-dir>\Library\​Java\Number.java  
Angular yes <data-dir>\Library\​Angular\number.pipe.ts <data-dir>\Samples\Angular\Number
Delphi yes <data-dir>\Library\​Delphi\NtNumber.pas <data-dir>\Samples\Delphi\VCL\Number
<data-dir>\Samples\Delphi\FMX\Number
Java yes <data-dir>\Library\​Java\Number.java  
JavaScript yes <data-dir>\Library\​JavaScript\number.js  
TypeScript yes <data-dir>\Library\​TypeScript\number.ts See the Angular sample

yes means that we have implemented an open-source API. To use the open-source API, include the plural API file into your project and start using the API. To see how to use the API, see the provided plural samples at <data-dir>\Samples\<platform>\Pattern directory.

built-in means that the standard API of the platform supports the feature. Only Angular has a built-in solution that matches Soluling API. Other platforms provide built-in support for plural parameters and/or gender but do not have a solution for multiple parameters or select. If your platform does not have built-in support and Soluling's API does not support it, you can easily write your own by viewing the implementation of one of the APIs we provide.