Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Lemondoge/Calc
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-------------This (test) module performs a calculation.------------- local p = {} local function RError(msg) return mw.ustring.format('<b class="error">%s</b>', msg) end function p.add(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 + num2 end function p.addition(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 + num2 end function p.minus(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 - num2 end function p.subtraction(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 - num2 end function p.times(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) local errordetect = tonumber(frame.args[3]) if num2 == 0 and errordetect ~= 1 then return RError("You cannot multiply a number by zero.") else return num1 * num2 end end function p.multiplication(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 * num2 end function p.double(frame) local num1 = tonumber(frame.args[1]) return num1 * 2 end function p.div(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) local antinotanumber = tonumber(frame.args[3]) if num1 == 0 and num2 == 0 and antinotanumber == 1 then return 1 else return num1 / num2 end end function p.division(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) local antinotanumber = tonumber(frame.args[3]) if num1 == 0 and num2 == 0 and antinotanumber == 1 then return 1 else return num1 / num2 end end function p.mod(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 % num2 end function p.modulo(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 % num2 end function p.exp(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 ^ num2 end function p.exponentiation(frame) local num1 = tonumber(frame.args[1]) local num2 = tonumber(frame.args[2]) return num1 ^ num2 end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Module:Sandbox/Lemondoge/Calc
(
edit
)
Module:Sandbox/Lemondoge/Calc/doc
(
edit
)