Difference between revisions of "Randomnumber"

From Mesham
Jump to navigationJump to search
(Created page with '== Overview == This randomnumber[n,x] function will return a random number between ''n'' and ''x''. ''Note: A whole number will be returned UNLESS you pass the bounds of 0,1 and …')
 
m (4 revisions imported)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
This randomnumber[n,x] function will return a random number between ''n'' and ''x''.
+
This randomnumber(n,x) function will return a random number between ''n'' and ''x''.
''Note: A whole number will be returned UNLESS you pass the bounds of 0,1 and in this case a decimal number is found.''
+
''Note: A whole number will be returned UNLESS you pass the bounds of 0,1 and in this case a floating point number is found.''
  
* '''Pass:''' Two integers defining the bounds of the random number
+
* '''Pass:''' Two [[Int|Ints]] defining the bounds of the random number
* '''Returns:''' A Double representing the random number
+
* '''Returns:''' A [[Double]] representing the random number
  
 
== Example ==
 
== Example ==
  
  var a:=randomnumber[10,20];
+
  #include <maths>
var b:=randomnumber[0,1]
+
 +
function void main() {
 +
    var a:=randomnumber(10,20);
 +
    var b:=randomnumber(0,1);
 +
};
  
In this case, ''a'' is a whole number between 10 and 20, whereas ''b'' is a decimal number
+
In this case, ''a'' is a whole number between 10 and 20, whereas ''b'' is a decimal number.
 +
 
 +
''Since: Version 0.41b''
  
 
[[Category:Function Library]]
 
[[Category:Function Library]]
 
[[Category:Maths Functions]]
 
[[Category:Maths Functions]]

Latest revision as of 15:44, 15 April 2019

Overview

This randomnumber(n,x) function will return a random number between n and x. Note: A whole number will be returned UNLESS you pass the bounds of 0,1 and in this case a floating point number is found.

  • Pass: Two Ints defining the bounds of the random number
  • Returns: A Double representing the random number

Example

#include <maths>

function void main() {
   var a:=randomnumber(10,20);
   var b:=randomnumber(0,1);
};

In this case, a is a whole number between 10 and 20, whereas b is a decimal number.

Since: Version 0.41b