Statement on glibc/iconv Vulnerability

Voting

: min(five, three)?
(Example: nine)

The Note You're Voting On

maikl
10 years ago
A correction to the funcion floor_dec from the user "php is the best".
If the number is 0.05999 it returns 0.59 because the zero at left position is deleted.
I just added a '1' and after the floor or ceil call remove with a substr.
Hope it helps.

function floor_dec($number,$precision = 2,$separator = '.') {
$numberpart=explode($separator,$number);
$numberpart[1]=substr_replace($numberpart[1],$separator,$precision,0);
if($numberpart[0]>=0) {
$numberpart[1]=substr(floor('1'.$numberpart[1]),1);
} else {
$numberpart[1]=substr(ceil('1'.$numberpart[1]),1);
}
$ceil_number= array($numberpart[0],$numberpart[1]);
return implode($separator,$ceil_number);
}

<< Back to user notes page

To Top