Negative random numbers

Is to possible to generate negative and positive random numbers in Flash? I know how to generate numbers from say 0 to 100 but what about generating random numbers from say… -100 to 100? I havent heard of this before but then again this is an unusual request.

Any help appreciated.

Chris

I don’t know if it’s directly possible… but certainly a work around could be produced.

negpos=random(2)
if negpos=0
neg=true
totalRandom=random(100)
totalRandom=TotalRandom+1
if neg=true
totalRandom=(totalRandom)*-1

bear with me if that example doesn’t work… I’m not much of a programer yet… none the less it should be something similar to that. :wink:

Ok thanks. I got it to work.

Chris

here’s a cleaner method:

num = Math.random()*200-100;

this makes num equal some number b/w -100 and 100.

really… Sweet…

See that’s what I love about flash… there are always a dozen ways of doing something…

Be forwarned… I only took algebra as my top level math… with math, I’m stumbling around in the dark.

Thanks again suprabeener