Skip to main content
Solved

Random number

  • February 3, 2021
  • 1 reply
  • 184 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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

redgeographics
Celebrity
Forum|alt.badge.img+62
  • 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