ID:1974036
 
Resolved
Constant values of log(base,value) were compiled backwards, e.g. log(2,8) was 1/3 instead of 3. Calls using vars, like log(2,n), compiled correctly.
BYOND Version:509.1311
Operating System:Windows 8 64-bit
Web Browser:Firefox 24.7
Applies to:Dream Maker
Status: Resolved (509.1312)

This issue has been resolved.
Descriptive Problem Summary:

Unable to pass variable to log()

Code Snippet (if applicable) to Reproduce Problem:
mob/verb/LogTest()
var/n = 3393

src << log(n,2)// Outputs 0.0852635

src << log(3393,2)// Outputs 11.7283


Expected Results:

Each output to be the same value.

Actual Results:

Outputs display different values.

Does the problem occur:
Every time? Or how often? Every time.
In other games? Not sure.
In other user accounts? Not sure.
On other computers? Not sure.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)

I actually upgrade from the stable release (508.1299) in hopes of fixing this error. Not sure about other versions.

Likely related:

log2(3393) == 11.728345714710978
log3393(2) == 0.0852635166394942

Is it mixing up the arguments somewhere?

edit:
/world/New()
var/a = 3393
var/b = 2
var/const/A = 3393
var/const/B = 2

world.log << "log(a,b) = [log(a,b)]"
world.log << "log(a,B) = [log(a,B)]"
world.log << "log(A,b) = [log(A,b)]"
world.log << "log(A,B) = [log(A,B)]"


log(a,b) = 0.0852635
log(a,B) = 0.0852635
log(A,b) = 0.0852635
log(A,B) = 11.7283

The reference says log(X,Y) is the logarithm of Y, base X. The correct answer in this case is 0.0852635, so it's calls with only constant arguments compiling backwards, by the looks of it.
It would seem you've hit the nail on the head.

mob/verb/LogTest()
var/n = 3393

src << log(2,n)// Outputs 11.7283

src << log(3393,2)// Outputs 11.7283


Reversing it fixes it. I would assume this is still an error though.
Constant-argument log() compiles backwards, yeah. With variables present it follows the ref.
Until this is addressed, you can probably resolve it by doing something like

#define log(x,y) log(y)/log(x)
That won't work, it gives error: incorrect number of macro arguments. The following does work, though you will need to change it everywhere you use two-argument log anyway:

#define logxy(x,y) log(y)/log(x)
Lummox JR resolved issue with message:
Constant values of log(base,value) were compiled backwards, e.g. log(2,8) was 1/3 instead of 3. Calls using vars, like log(2,n), compiled correctly.