php - why does floor round down a integer? -
Why I am confused as:
Echo log 10 (238328) / Log 10 (62);
Results in 3
but
echo floor (log 10 (238328) / log 10 (62));
Results in 2
I know that the floor is round, but I thought it was only for decimal numbers.
How can I get answers 3 of the latter statements are still going round normally? PHP uses dual-precise floating point numbers; the results of two logarithm can not be perfectly represented, so the result of sharing them is
Not accurate. The results you received are close, but slightly less than 3. When it is formatted with echo
, it becomes round on 3. floor
, still returns 2.
You can take advantage of this fact to avoid disqualification from the log (x, b) / log (y, b)
log (x, y) (for any base
b
). Instead, instead of giving you the expression log (238328, 62)
, whose exact point of 3 is the point of the result (correct result from 238328 pow (62, 3)
).
Comments
Post a Comment