note 26701 deleted from ref.math by cmb
| From: | cmb@php.net | Date: | Sun, 21 Jul 2019 09:02:38 +0000 |
| Subject: | note 26701 deleted from ref.math by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211667@lists.php.net to get a copy of this message | ||
Note Submitter: jbeardsl at gte dot net
----
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);
}