import math from Custom import CustomBase import API class ln (CustomBase): stack = None def __init__(self, stack): self.stack = stack # __init__ def help(self): msg = "ln\n" msg += "--\n\n" msg += "Takes r0 from the stack\n\n" msg += "Calculates the natural logarithn of r0\n\n" msg += "Pushes the result to r0" API.showPopup('Custom function', msg, font=('Courier',API.helpFontSize)) # help def calculate(self): if self.stack.inputMode != 'DEC': API.toast('This operation is only supported in DEC mode') return if self.stack.finishEntry() == -1: return # abort here because data in input line is invalid if self.stack.size() < 1: API.beep() API.toast('This operation needs 1 argument') return x = self.stack.getRegister(0) self.stack.pop(1) self.stack.push(math.log(x)) # calculate # log