5 Rappen CHF rounding (Rounding to nearest 5 cents) + Swiss Franc + Angular Pipe

Balram Chavan
2 min readDec 12, 2022

How would you implement conversation logic for below requirements?

For example,

  • Values between CHF 0,975 and CHF 1,024 will be rounded to CHF 1,00
  • Values between CHF 1,025 and CHF 1,074 will be rounded to CHF 1,05
  • Values between CHF 1,075 and CHF 1,124 will be rounded to CHF 1,10

This conversation rule is commonly referred as “5 Rappen rounding” mostly used in Switzerland and Liechtenstein region for accounting and banking purposes.

You can read more details here.

Angular Pipe

If you want to use this conversation logic in your Angular application, I have published a NPM package to do so.

This package consists of an Angular Pipe, which you can apply in your HTMl or in Component TypeScript file.

Using Pipe in Component’s HTML

--

--