Skip to main content
Solved

Random number

  • February 3, 2021
  • 1 reply
  • 156 views

abinash

Hi Guys,

 

Can anybody help me with this.

 

In condition statement i putted if a like b value is @int@rand()*4 which gave me random value 0,1,2,3.

 

Now in else i want to put rand value 6, 7,8

 

How can i do this ??

 

It would be a great help

 

Thank you 😊

Best answer by redgeographics

The @rand() function generates a random number between 0 and 1, so 

@int(@rand()*4)
  • generates a random number between 0 and 1
  • multiplies that by 4
  • creates an integer (value without decimals) out of it.

Note the brackets there by the way, the function you posted results in <null> values.

 

In order to get a random value of 6-7-8 you could do

(@int(@rand()*3))+6

Alternatively, a RandomNumberGenerator will let you set upper and lower bounds for the random numbers

View original
Did this help you find an answer to your question?

1 reply

redgeographics
Celebrity
Forum|alt.badge.img+49
  • Celebrity
  • Best Answer
  • February 3, 2021

The @rand() function generates a random number between 0 and 1, so 

@int(@rand()*4)
  • generates a random number between 0 and 1
  • multiplies that by 4
  • creates an integer (value without decimals) out of it.

Note the brackets there by the way, the function you posted results in <null> values.

 

In order to get a random value of 6-7-8 you could do

(@int(@rand()*3))+6

Alternatively, a RandomNumberGenerator will let you set upper and lower bounds for the random numbers


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings