Statement on glibc/iconv Vulnerability

Voting

: two plus two?
(Example: nine)

The Note You're Voting On

php is the best
12 years ago
Floor decimal numebrs with precision:

function floor_dec($number,$precision,$separator)
{
$numberpart=explode($separator,$number);
$numberpart[1]=substr_replace($numberpart[1],$separator,$precision,0);
if($numberpart[0]>=0)
{$numberpart[1]=floor($numberpart[1]);}
else
{$numberpart[1]=ceil($numberpart[1]);}

$ceil_number= array($numberpart[0],$numberpart[1]);
return implode($separator,$ceil_number);
}

echo floor_dec(1.125,2,"."); //1.12
echo floor_dec(-1.3436,3,"."); //-1.344
echo floor_dec(102938.1,4,"."); //102938.1

<< Back to user notes page

To Top