Go Down

Topic: Random() Maximum (Read 1 time) previous topic - next topic

woo_oow

Hello there!

I need to create by random really large numbers.
Does the random() function whose type is set as "long", return numbers in the range of long?
between 0 and 2,147,483,647?
when i try to check it by printing the value over serial, it returns always 16807.

any suggestions?

woo_oow

#1
Jul 14, 2007, 02:22 am Last Edit: Jul 14, 2007, 02:02 pm by woo_oow Reason: 1
mh.
im not shure yet.
i thought about the serial.
What is the maximum value i can transmit over serial?
is it the "int" range?
if it is so, how can i send values of the size of "long" over the serial?
(perhaps i should start another topic for that)

woo

kg4wsv

what does your random() call look like?

Integer constants that you want to be of type long need an "L" at the end, e.g.  i = random(2000000L);

-j

woo_oow

at the moment it looks like:

long x = random(1576800000);
(actually its the amount of seconds of 50 years)

so it should look like: long x = random(1576800000L);?


thanks
w


kg4wsv

Quote
so it should look like: long x = random(1576800000L);

that's correct.

-j

Go Up