note 13048 added to language.types.double.php
| From: | jeroen@php.net | Date: | Wed, 23 May 2001 23:13:35 +0000 |
| Subject: | note 13048 added to language.types.double.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14208@lists.php.net to get a copy of this message | ||
If you want to round a floating point number to the nearest multiple of some number n, use the
following trick:
$rounded = round($number / n) * n
For example, to round 12874.49 to the nearest 100-multiple (i.e. 12900), use
$rounded = round($number / 100) * 100
http://www.php.net/manual/en/language.types.double.php