Hello,
elyob wrote:
How can I get -0.162058 to -0.1 rather than rounding to -0.2?
I know I'm being stupid here, but it's really bugging me. The number
before the decimal point could 0 - 999
After making a function myself that was just far more complex
than needed, I saw in the user contributed notes of the manual
that someone contributed a suggestion for such function :
jbeardsl [found_at] gte [d0t] net
08-Nov-2002 01:15
I was looking for a truncate function. Not finding one, I wrote my own.
Since it deals with everything as a number, I imagine it's faster than the
alternative of using string functions. 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);
}
Best regards,
Eric