xHarbour Reference Documentation > Function Reference |
Generates a random integer number between two boundaries.
HB_RandomInt( [<nMaxLimit>] ) --> nRandomInteger or HB_RandomInt( <nMinLimit>, <nMaxLimit> ) --> nRandomInteger
The function returns a random integer value, limited by the two boundaries.
This function generates a random number between two boundaries. The boundary values are included in the range. When only one boundary is passed to the function, it is considered the maximum boundary. The minimum boundary, in that case, is zero. When no boundaries are passed, the function returns 0 or 1.
Note Use function HB_Random() to generate random numeric values with two decimals.
See also: | HB_Random(), HB_RandomSeed() |
Category: | Numeric functions , Random generator , xHarbour extensions |
Source: | rtl\hbrandom.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the three possibilities of generating // random numbers with HB_RandomInt(). PROCEDURE Main // Random creation of 0 and 1 ? HB_RandomInt() // Random number between 0 and 10 ? HB_RandomInt(10) // Random number between 8 and 10 ? HB_RandomInt(8,10) RETURN
http://www.xHarbour.com