Here test sample:
Uses "Console"
Dim result As Number
result = Logarithm(3, 243)
PrintL "LOG3(243) = ", result
PrintL "AntiLOG3("+Format$(result)+") = ", AntiLogarithm(3, result)
PrintL
result = Log2(64)
PrintL "LOG2(64) = ", result
PrintL "AntiLOG2("+Format$(result)+") = ", AntiLogarithm(2, result), "=", AntiLog2(result)
PrintL
result = Log10(1000)
PrintL "LOG10(1000) = ", result
PrintL "AntiLOG2("+Format$(result)+") = ", AntiLogarithm(10, result), "=", AntiLog10(result)
PrintL
result = Log(M_E^2)
PrintL "LOGe(e^2) = ", result
PrintL "AntiLOGe("+Format$(result)+") = ", AntiLogarithm(M_E, result), "=", AntiLog(result)
PrintL
WaitKey
' -- General purpose
Function AntiLogarithm(nBase As Ext, nValue As Ext) As Ext
Return nBase^nValue
End Function
Function Logarithm(nBase As Ext, nValue As Ext) As Ext
Return Log10(nValue)/Log10(nBase)
End Function
' -- Or to directly map to ThinBASIC LOG10, LOG2 and LOG (called LN on calculator)
Function AntiLog10(nValue As Ext) As Ext
Return 10^nValue
End Function
Function AntiLog2(nValue As Ext) As Ext
Return 2^nValue
End Function
Function AntiLog(nValue As Ext) As Ext
Return M_E^nValue
End Function
Petr
Bookmarks