LogB - swapped parameters issue
issueid=338 21-11-2011 22:09
Super Moderator
Number of reported issues by Petr Schreiber: 129
LogB - swapped parameters issue
LogB has incorrectly swapped parameter handling

There is a problem with LogB.

Log2(x) - works okay
Log10(x) - works okay
LogB(base, x) - works wrong!

This is because instead of Log2(x)/Log2(base) it is calculated in reverse as Log2(base)/Log2(x).

The test case is simple:
Uses "Console"

PrintL LogB(2, 8), Log2(8)       ' -- Both should give 3, LogB doesn't give correct result
PrintL LogB(10, 100), Log10(100) ' -- Both should give 2, LogB doesn't give correct result

WaitKey
One of the solutions could be to change documentation :) But I think it would be good to keep the first param base and second the x, because only this way it will be consistent with Log2 and Log10 style.


Petr
Issue Details
Issue Number 338
Project thinBasic
Category Core engine (thinCore.dll)
Status Fixed
Priority 2
Affected Version 1.8.9
Fixed Version 1.9.1
Milestone thinBasic 1.9.0.0
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




21-11-2011 22:52
thinBasic author
Thanks Petr.
The problem is not the formula but the parsing. It currently is parsing the Number and than the Base while it should parse the other way round

Ciao
Eros

22-11-2011 01:44
thinBasic author
Updated 1.9 that is online at the usual url

Ciao
Eros

22-11-2011 20:06
Super Moderator
Perfect, thanks! :)

+ Reply