t2:rand

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

t2:rand [2016/11/12 15:29]
J2Kbr created
t2:rand [2021/02/22 09:31] (current)
scachi [Examples]
Line 19: Line 19:
 <code gpc2>​init { <code gpc2>​init {
     printf("​%.6f",​ rand()); // Random number between 0.0 and 1.0     printf("​%.6f",​ rand()); // Random number between 0.0 and 1.0
 +}</​code>​
 +
 +=== Example #2 int16 example ===
 +<code gpc2>​init {
 +    printf("​%d",​ irand(200,​500));​ // Random number between 200 and 500
 +}
 +
 +int16 irand(int16 vmin, int16 vmax) {
 +    return(((int16)(rand() * (fix32)(vmax + 1 - vmin))) + vmin);
 }</​code>​ }</​code>​
t2/rand.txt · Last modified: 2021/02/22 09:31 by scachi