Reputation: 2452
I am trying to round the numbers like below
$num = 6.91227556465E-8;
echo round($num);
This results in 0 . I tied adding (float) before number , still I get zero , Expected result is 7.
Upvotes: 1
Views: 512
Reputation: 360702
RTM: http://php.net/round
float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] )
^^^^^^^^^^^^^^^^^^
You specified no precision, so a default of 0
decimal places is used, And since your number is actually
0.0000000691227etc...
you get 0 upon rounding, exactly as it should be.
php > echo round($num, 8);
7.0E-8
Note the extra parameter...
Upvotes: 2