Reputation: 31
I'm shocked about the difference between log and log(double) in matlab. as I know, log(255) = 2.4065... but my matlab is 5.5413. How could it difference between them? Is this bug?
Upvotes: 0
Views: 73
Reputation: 8401
Matlab's log
function is base e
(that's your 5.54...
). I think you're looking for log10
(that's your 2.40...
).
Most programming languages that come to mind (MATLAB, Fortran, C, PHP, Javascript) default to using log
for the natural logarithm without a base specified.
I'd say, arguably, it is because logarithms involving e
are much more prevalent than those involving 10
(though they are usually important enough to receive a function of their own).
Upvotes: 4