LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HELP I'M NEW TO CODING BUT HAVE A PROJECT (BASIC)


@Thomas_robertson wrote:

Good point.   I'll bet I coded some randomize routines wrong in the past...  So round down is always the right thing to do.  NI should revamp the random number function such that you can type in a range.


That very idea was suggested on the Idea Exchange some time ago.

 

Random number function improvement

0 Kudos
Message 11 of 15
(649 Views)

@Thomas_robertson wrote:

Good point.   I'll bet I coded some randomize routines wrong in the past...  So round down is always the right thing to do.  NI should revamp the random number function such that you can type in a range.


The OpenG Numeric library has this already.  You can add it from the VIPM.  It will be called Random Number within Range

0 Kudos
Message 12 of 15
(637 Views)

If you multiply by 3 and round down won't you get a number 0-3?  If you then add one, you'll get 1-4.  So what do you do to avoid the (rare) situation of getting 1.0000000  out of the random number generator?

0 Kudos
Message 13 of 15
(580 Views)

@Thomas_robertson wrote:

If you multiply by 3 and round down won't you get a number 0-3?  If you then add one, you'll get 1-4.  So what do you do to avoid the (rare) situation of getting 1.0000000  out of the random number generator?


You won't.  Just read the help.

 

"The number generated is greater than or equal to 0, but less than 1"

0<=x<1

 

So when you do a multiply by 3 and round down, you get 0 to 2.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 15
(569 Views)

@Thomas_robertson wrote:

If you multiply by 3 and round down won't you get a number 0-3?  If you then add one, you'll get 1-4.  So what do you do to avoid the (rare) situation of getting 1.0000000  out of the random number generator?


If you read what I wrote,  1.00000 is not returned by the random number generator.  Is it 0.9999999.....

0 Kudos
Message 15 of 15
(557 Views)