# \[SOLVED\] How ensure random is same on different platforms?

**URL:** <https://forum.defold.com/t/solved-how-ensure-random-is-same-on-different-platforms/83198>\
**Category:** Questions\
**Created:** [September 4, 2026, 9:07am UTC](https://forum.defold.com/t/solved-how-ensure-random-is-same-on-different-platforms/83198 "2026-09-04T09:07:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boruok](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/boruok/32/21851_2.png) [@boruok](https://forum.defold.com/u/boruok)\
**Post date:** [September 4, 2026, 9:07am UTC](https://forum.defold.com/t/solved-how-ensure-random-is-same-on-different-platforms/83198/1 "2026-09-04T09:07:17Z")

</div>

I’ve heard somewhere that math.random function can return different values on different platforms with same seed, is here any workaround or lib recommendations?

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [September 4, 2026, 9:11am UTC](https://forum.defold.com/t/solved-how-ensure-random-is-same-on-different-platforms/83198/2 "2026-09-04T09:11:20Z")

</div>

> **[Defold Asset Portal](https://defold.com/assets/?q=random)**
>
> Browse Defold extensions, templates, tools, shaders, and reusable game-development assets from the community asset portal.

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [September 4, 2026, 9:31am UTC](https://forum.defold.com/t/solved-how-ensure-random-is-same-on-different-platforms/83198/3 "2026-09-04T09:31:43Z")

</div>

While it may generally be true that they differ given Lua versus LuaJIT and different versions, it isn’t true in our version.

We implement our own [math.random()](https://github.com/defold/defold/blob/dev/engine/script/src/script.cpp#L186) which calls our own [dmMath::Rand()](https://github.com/defold/defold/blob/dev/engine/dlib/src/dlib/math.h#L88-L92) function.

That code isn’t complex, and while we only have a small unit test for it, we run it on all desktops, web, android and consoles. So if you _do_ find a difference between platforms, let us know and provide a repro case.
