Round down to 5 Rappen

Skip to main content
Du bist hier:
Drucken

Round down to 5 Rappen

Rounding down in PHP

The following example shows how to round down to 5 Rappen in PHP:

 

[code lang=”php”]
$sum = floor($sum*20)/20;
[/code]

 

The number is first multiplied by 100 to get the amount in Rappen and then divided by 5 (100/5=20). The result is then simply rounded down. This tells you how many 5s fit into the number. The number is then divided by 100 and multiplied by 5, so that you have an amount in Swiss francs (CHF) again.

Related Post