LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I generate a random integer from 1-5?

Solved!
Go to solution
Funny when I run this code it give me 1-6.
Tim
GHSP
0 Kudos
Message 11 of 26
(6,678 Views)

I just tried the code and get 1-5.

I dont know where the error could be sorry.

Pattos

LabVIEW Gretchin
0 Kudos
Message 12 of 26
(6,672 Views)

aeastet wrote:
Funny when I run this code it give me 1-6.

 

This post makes absolutely no sense unless you tell us which, of all the many versions above, you mean by "this code". 😄

 

(It certainly cannot be mine, unless you don't copy it right and e.g. confuse "round to -inf" with "round to nearest", for example.).

 

Why don't you attach the code that does not work so we can have a look. 😉

0 Kudos
Message 13 of 26
(6,657 Views)

 


 altenbach wrote:

 

This post makes absolutely no sense unless you tell us which, of all the many versions above, you mean by "this code". :smileyvery-happy:

 

(It certainly cannot be mine, unless you don't copy it right and e.g. confuse "round to -inf" with "round to nearest", for example.).

 

Why don't you attach the code that does not work so we can have a look. :smileywink:


 

You are correct I did get the round to mixed up. Sorry.

Tim
GHSP
0 Kudos
Message 14 of 26
(6,645 Views)
Message Edited by aeastet on 01-20-2010 10:34 AM
Tim
GHSP
0 Kudos
Message 15 of 26
(6,644 Views)
Message Edited by aeastet on 01-20-2010 10:34 AM
Tim
GHSP
0 Kudos
Message 16 of 26
(6,644 Views)

I know that this is totally uncalled for, but:

 

MU-MU-MU-MULTIPOST!!! 😄

Pattos

LabVIEW Gretchin
0 Kudos
Message 17 of 26
(6,605 Views)
THe web site was doing funny things on my end yesterday. It was not intentional.
Tim
GHSP
0 Kudos
Message 18 of 26
(6,603 Views)

random1to5.png

 

Here is my random 1..5 using Round Toward +Infinity. does not need +1

 

Another thing i wanted to add to this thread is random gives you a number between 0 and 1. You dont get 0 or 1 back from the random number. you may get .9999 or 0.00001 but not 1 or 0. A previous post said you dont get 1 which is half true.

0 Kudos
Message 19 of 26
(6,272 Views)

almighty wrote:

Another thing i wanted to add to this thread is random gives you a number between 0 and 1. You dont get 0 or 1 back from the random number. you may get .9999 or 0.00001 but not 1 or 0. A previous post said you dont get 1 which is half true.


Let's be clear here:  0 is possible; very, very unlikely; but possible.  1 is not possible.  By your standard you don't get 0.5 (or any specific value you choose like 0).

 

While I am here, this is my generic random integer generator [Start..Stop].

 

RandomInteger.png

Message 20 of 26
(6,258 Views)