Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Random/doc
(section)
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!
== Number == The <code>number</code> function outputs a random number. {{#invoke:random|number|''m''|''n''|same=''yes''}} The arguments <code>m</code> and <code>n</code> may be omitted, but if specified must be convertible to integers. * With no arguments, returns a real number in the range <math>[0,1)</math>. * With one argument, returns an integer in the range <math>[1,m]</math>, or, if <code>''m''</code> is negative, <math>(-m,0]</math>. If <code>''m''</code> is equal to 0 or 1, returns 1 (or 0 if <math>m=-1</math>). * With two arguments, returns an integer in the range <math>[m,n]</math>. <code>''m''</code> and <code>''n''</code> can be either positive or negative. If <code>''m''</code> is greater than <code>''n''</code>, returns an integer in the range <math>[n,m]</math> instead. * If the {{para|same}} parameter is set to "yes", "y", "true", or "1", the same random number is returned for each module call on a given page. '''Examples''' <small>({{purge|refresh|anchor=Number}})</small> * <code><nowiki>{{#invoke:random|number}}</nowiki></code> → {{#invoke:random|number}} * <code><nowiki>{{#invoke:random|number|100}}</nowiki></code> → {{#invoke:random|number|100}} * <code><nowiki>{{#invoke:random|number|-100|-50}}</nowiki></code> → {{#invoke:random|number|-100|-50}} * <code><nowiki>{{#invoke:random|number|100|same=yes}}</nowiki></code> → {{#invoke:random|number|100|same=yes}} * <code><nowiki>{{#invoke:random|number|100|same=yes}}</nowiki></code> → {{#invoke:random|number|100|same=yes}} <small>The documentation for this function is partly taken from the [[mw:Extension:Scribunto/Lua reference manual#math.random|Scribunto Lua reference manual]], which is in turn based on the [http://www.lua.org/manual/5.1/index.html Lua 5.1 Reference Manual], available under the [[MIT License]].</small>
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)