note 26701 added to ref.math
| From: | jbeardsl at rack1 dot php dot net | Date: | Sat, 09 Nov 2002 16:36:06 +0000 |
| Subject: | note 26701 added to ref.math | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39221@lists.php.net to get a copy of this message | ||
I needed a truncate function to operate on real numbers. I preferred not to use a
string-manipulation method, so here's my solution. HTH...
function truncate ($num, $digits = 0) {
//provide the real number, and the number of
//digits right of the decimal you want to keep.
$shift = pow(10 , $digits);
return ((floor($num * $shift)) / $shift);
}
--
http://www.php.net/manual/en/ref.math.php
http://master.php.net/manage/user-notes.php?action=edit+26701
http://master.php.net/manage/user-notes.php?action=delete+26701
http://master.php.net/manage/user-notes.php?action=reject+26701