$val = 1000000
$val2 = floor(log($val,10)) gives a value of 5 for $val2 and not 6 as expected.
$val2 = floor(log10($val)) gives the correct value.
![]() | log说明float log ( float arg [, float base] )如果指定了可选的参数 base,log() 返回 logbase arg,否则 log() 返回参数 arg 的自然对数。
参见 exp()。 ![]()
mcmeijer at yahoo dot com
03-Feb-2005 11:22
$val = 1000000
c0x at mail dot ru
19-Sep-2004 06:08
more general version, works fine on negative, very big ($value > 1E+18) and very small ($value < 1E-18) numbers.
admin at worldtakeover dot tk
21-Jun-2004 04:06
In regards to the note about log in base 10 and the round() function. You need to use floor() instead of round() to find out the order of magnitude. That way, you don't have to worry about subtracting 0.5 or whatever.
mightye (at) mightye.org
07-Feb-2003 04:02
A minor warning: | ![]() |