Posted by Hero Wanders on 08/28/05 02:24
Hello!
>>I'd like to write a function who return a float with only two digits
>>after the point.
>>
>>For instance : 12.34567 -> 12.34
>>
>
> http://www.php.net/round
That *rounds* the value instead of returning the float with only the
last to digits of it (ok actually Thierry asked for a function which
returns *a* float (function give($float) { return 3.14; } would do it)).
I think
function cutFloat($float)
{
return (float) floor($float*100)/100;
}
is what Thierry really searches.
Greetings,
Hero Wanders
Navigation:
[Reply to this message]
|