xHarbour Reference Documentation > Function Reference |
Generates a random number between two boundaries.
HB_Random( [<nMaxLimit>] ) --> nRandomNumber or HB_Random( <nMinLimit>, <nMaxLimit> ) --> nRandomNumber
The function returns a random numeric value with two decimal digits, limited by the two boundaries.
This function generates a random number between two boundaries. The boundary values are excluded from 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 a number between 0.00 and 1.00.
Note Use function HB_RandomInt() to generate random integer values.
See also: | HB_RandomInt(), 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_Random(). PROCEDURE Main // Random number between 0.01 and 0.99 ? HB_Random() // Random number between 0.01 and 9.99 ? HB_Random(10) // Random number between 8.01 and 9.99 ? HB_Random(8,10) RETURN
http://www.xHarbour.com