# Why is 'random()' depreciated

**URL:** <https://forum.kirupa.com/t/why-is-random-depreciated/27506>\
**Category:** Uncategorized\
**Created:** [August 3, 2003, 10:22am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506 "2003-08-03T10:22:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jingman](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jingman/32/163_2.png) [@jingman](https://forum.kirupa.com/u/jingman)\
**Post date:** [August 3, 2003, 10:22am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/1 "2003-08-03T10:22:01Z")

</div>

I use it all the time.

random(2) = Math.round(Math.random());

gimme a break.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 10:30am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/2 "2003-08-03T10:30:41Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 10:33am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/3 "2003-08-03T10:33:34Z")

</div>

> \*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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 10:35am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/4 "2003-08-03T10:35:30Z")

</div>

:beam:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 10:39am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/5 "2003-08-03T10:39:24Z")

</div>

Hoi

i guess Macromedia whated to do it all in a more OO way :sure:

oh this should be better

```auto

random(2) = Math. **floor** (Math.random()*2);

```

:thumb:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 10:40am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/6 "2003-08-03T10:40:11Z")

</div>

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 :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 11:37am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/7 "2003-08-03T11:37:24Z")

</div>

> \*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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 1:50pm UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/8 "2003-08-03T13:50:24Z")

</div>

I remember someone saying that Math.random() is more random than random() but I see no difference! :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 2:32pm UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/9 "2003-08-03T14:32:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2003, 3:47pm UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/10 "2003-08-03T15:47:59Z")

</div>

Maybe their just the same…  
just that random is global and Math.random isn’t!!  
:-\

[SIZE=1]just an idea [/SIZE] 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 4, 2003, 5:41am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/11 "2003-08-04T05:41:02Z")

</div>

> \*Originally posted by Master64 \*  
> \*\*Maybe their just the same…  
> just that random is global and Math.random isn’t!!  
> :-\

[SIZE=1]just an idea [/SIZE] 🙂 \*\*

i guess it just goes back to having everything more object oriented like you said before.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 4, 2003, 5:44am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/12 "2003-08-04T05:44:44Z")

</div>

> \*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)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 4, 2003, 5:53am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/13 "2003-08-04T05:53:24Z")

</div>

why dont you post it again, i’d like to see it

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 4, 2003, 5:57am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/14 "2003-08-04T05:57:07Z")

</div>

> \*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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 4, 2003, 6:03am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/15 "2003-08-04T06:03:05Z")

</div>

gotcha…

nice!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 4, 2003, 11:27am UTC](https://forum.kirupa.com/t/why-is-random-depreciated/27506/16 "2003-08-04T11:27:01Z")

</div>

very nice jingman! =)

lol @ phil 😛
