In my game, I'm trying to create a way for my players to add audio equipment to their vehicles, and to compete in sound offs. So I'm trying to make it a little realistic and I looked up a SPL calculator online, and trying to mimic what they did.
I found this one
http://myhometheater.homestead.com/splcalculator.html
so I downloaded the excel version, and looking at the formulas.
This is where I'm getting stuck.
Under Power if you put 1000 in the next column it calculates the db value using this formula.
=10*LOG(Power)
the result 30
So now in PHP I tried to do the same thing.
for testing I hardcoded the values
$power = 1000;
$db1 = 10*log($power);
but when I echo the result I get
169.0775527898???
I also looked at the comments here
http://us2.php.net/log
and tried
$db1 = 10*floor(log10($power));
$db1 = 10 * log($power, 10);
and
$db1 = 10 * log10($power);
these give me a result of 130?
what do I need to do, to get the same outcome as the example?
Can't get log() to give expected results
Moderator: General Moderators
Re: Can't get log() to give expected results
Code: Select all
$power = 1000;
$db1 = 10 * log($power, 10);
echo $db1;