question

Gary Q2 avatar image
0 Likes"
Gary Q2 asked Gary Q2 commented

code to generate random numbers

How do I generate random numbers and print that information in the output console that I write? I'm just using a source and sink I would appreciate a help

Choose One
code c+
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeff Nordgren avatar image
1 Like"
Jeff Nordgren answered Gary Q2 commented

@Gary Q2

A random whole number a random decimal number, what? If you are wanting a random whole number between 1 and 100, you would write something like this:

print(duniform(1, 100)); //Prints the number to the output console

Is this what you are looking for?

· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image Joerg Vogel commented ·
print( value or string, value or string, value or string,..) 

is a new command to write in the output console

1 Like 1 ·
Gary Q2 avatar image Gary Q2 commented ·

Generate numbers from 0 to 1, I do not print the numbers in the output console: the code you used was in the triggers on exit tab double ran = randnext (1); pf (ran); pt (""); What error is there ?? @Jeff Nordgren

0 Likes 0 ·
Ben Wilson avatar image Ben Wilson ♦♦ Gary Q2 commented ·

@Gary Q2,

uniform(0,1) will give a real number between 0 and 1.

0 Likes 0 ·
Jeff Nordgren avatar image Jeff Nordgren Gary Q2 commented ·

@Gary Q2,

Not exactly sure what you are after. The answers that @Ben Wilson and @Jörg Vogel gave seem to answer your question. If they don't answer your question, can you explain why they don't?

Thanks.

0 Likes 0 ·
Gary Q2 avatar image Gary Q2 commented ·
thank you very much for the help, I found the expected result
Thank you
0 Likes 0 ·
Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Jeff Nordgren edited

@Gary Q2, duniform( number left side, right side of the interval, number of the. random number stream) if you are looking for discrete values.

uniform( left side or minimum value, right side or maximum value, random number stream) for a continuous floating number interval as double.

double numberRandom = uniform(0,1,0); // random interval ]0..1[
print(numberRandom); // print random number
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.