cdoyle Posted September 6, 2009 Share Posted September 6, 2009 Hi, I've never used this before, but here is what I'm trying to do. 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)); that just gives me 130 what do I need to do, to get the similar numbers as the example I'm using? Quote Link to comment https://forums.phpfreaks.com/topic/173338-need-help-with-log/ Share on other sites More sharing options...
ignace Posted September 6, 2009 Share Posted September 6, 2009 In Excel, the Log function returns the logarithm of a number to a specified base. The syntax for the Log function is: Log( number, base ) number is a numeric value that must be greater than 0. base is optional. This is the base to use to calculate the logarithm of a number. If this parameter is omitted, the Log function will use a base of 10. $db1 = 10 * log($power, 10)); or $db1 = 10 * log10($power); Quote Link to comment https://forums.phpfreaks.com/topic/173338-need-help-with-log/#findComment-913714 Share on other sites More sharing options...
cdoyle Posted September 6, 2009 Author Share Posted September 6, 2009 In Excel, the Log function returns the logarithm of a number to a specified base. The syntax for the Log function is: Log( number, base ) number is a numeric value that must be greater than 0. base is optional. This is the base to use to calculate the logarithm of a number. If this parameter is omitted, the Log function will use a base of 10. $db1 = 10 * log($power, 10)); or $db1 = 10 * log10($power); thanks, but I tried these and I get 130 when I use a power of 1000? Quote Link to comment https://forums.phpfreaks.com/topic/173338-need-help-with-log/#findComment-913717 Share on other sites More sharing options...
cdoyle Posted September 6, 2009 Author Share Posted September 6, 2009 argh, I see what I did. Thank you for double checking for me. Quote Link to comment https://forums.phpfreaks.com/topic/173338-need-help-with-log/#findComment-913739 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.