PDA

View Full Version : int(Math.random()*200)+100


farafiro
01-21-2002, 08:39 AM
Can any body tell me what this means ??
I might look silly but isn'r it useless unless u put a number between the () of the RANDOM ???

Jesse
01-21-2002, 09:45 AM
No, by default Math.random() returns a decimal between zero and 1. Multiplying it by 200 gives you a random number between 0 and 200, but it woudl still have decimal places, so they use Int() to round it. Then add 100.

farafiro
01-21-2002, 09:51 AM
Thanks Jesse
But wouldn't it be the same as If I wrote
(Math.random (200))+100
and no use to the int

red penguin
01-22-2002, 08:10 AM
I've used this syntax in the past...random(200)+100....and that'll still work in F5, at least to my knowledge. But with the Math object now, we would use as Jesse said....

progression and all

tg
01-22-2002, 10:15 PM
try it, see what happens, its the best way to learn...

trace((Math.random (200))+100);

Jesse
01-23-2002, 12:47 AM
MM say in the AS Dictionary that Math.random() is to return a decimal between 0 and 1. Random() is the old Flash 4 function, and it's not part of the Math class.. well not really, sinceit's not a method.
Method; returns a pseudo-random number between 0.0 and 1.0.
My point it that I don't think Math.random() is supposed to take an argument between the braces.

red penguin
01-23-2002, 01:13 AM

farafiro
01-23-2002, 08:24 AM
When I used this :
Originally posted by tg
try it, see what happens, its the best way to learn...

trace((Math.random (200))+100);

It turned (100. xxxxxxxxxxxxxxxx)
but when I added int, so it tured 100 always

so I used mine which in the first post here and it turned numbers with no dic. between 100 - 300

Thanks all