View Full Version : why is 'random()' depreciated
jingman
August 3rd, 2003, 06:22 AM
I use it all the time.
random(2) = Math.round(Math.random());
gimme a break.
claudio
August 3rd, 2003, 06:30 AM
I dunno why it was deprecated, but:
random(2) is not the same as Math.round(Math.random()*2);
random(2) return an integer between 0 and 2, not including 2;
Math.round(Math.random()*2) return an integer between 0 and 2 (included).
jingman
August 3rd, 2003, 06:33 AM
Originally posted by claudio
I dunno why it was deprecated, but:
random(2) is not the same as Math.round(Math.random()*2);
random(2) return an integer between 0 and 2, not including 2;
Math.round(Math.random()*2) return an integer between 0 and 2 (included).
Hehe, I beat you to it (the fix) :) thanks though.
claudio
August 3rd, 2003, 06:35 AM
:beam:
Johnny64
August 3rd, 2003, 06:39 AM
Hoi
i guess Macromedia whated to do it all in a more OO way :sure:
oh this should be better
random(2) = Math.floor(Math.random()*2);
:thumb:
ahmed
August 3rd, 2003, 06:40 AM
I don't really know why, but i assume it has something to do with the fact that after flash 4, ActionScript followed the ECMA standards :) .. the old random() is faster than Math.random() though :-\
senocular
August 3rd, 2003, 07:37 AM
Originally posted by ahmed
I don't really know why, but i assume it has something to do with the fact that after flash 4, ActionScript followed the ECMA standards :) .. the old random() is faster than Math.random() though :-\
ding ding!
andr.in
August 3rd, 2003, 09:50 AM
I remember someone saying that Math.random() is more random than random() but I see no difference! :-\
senocular
August 3rd, 2003, 10:32 AM
someone here did a really good thing on how random is random, plugging in the values in excel and making a chart and everything - that was pretty wild, but I dont think they compared random to Math.random. I think it was just random. ... so I dont know if one is more random than the other or not :-\
... I think I might have heard the same though
Johnny64
August 3rd, 2003, 11:47 AM
Maybe their just the same...
just that random is global and Math.random isn't!!
:-\
just an idea :)
norie
August 4th, 2003, 01:41 AM
Originally posted by Master64
Maybe their just the same...
just that random is global and Math.random isn't!!
:-\
just an idea :)
i guess it just goes back to having everything more object oriented like you said before.
jingman
August 4th, 2003, 01:44 AM
Originally posted by senocular
someone here did a really good thing on how random is random, plugging in the values in excel and making a chart and everything - that was pretty wild, but I dont think they compared random to Math.random. I think it was just random. ... so I dont know if one is more random than the other or not :-\
... I think I might have heard the same though
Hey, that was ME! (http://www.kirupaforum.com/forums/showthread.php?s=&threadid=24816)
norie
August 4th, 2003, 01:53 AM
why dont you post it again, i'd like to see it
jingman
August 4th, 2003, 01:57 AM
Originally posted by norie
why dont you post it again, i'd like to see it
My previous post was a link, I know sometimes it's hard to tell.
norie
August 4th, 2003, 02:03 AM
gotcha..........
nice!
senocular
August 4th, 2003, 07:27 AM
very nice jingman! =)
lol @ phil :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.