# Maximum number in randomSeed() p5js

**URL:** <https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352>\
**Category:** Beginners\
**Created:** [June 6, 2022, 10:21am UTC](https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352 "2022-06-06T10:21:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nik](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@Nik](https://discourse.processing.org/u/Nik)\
**Post date:** [June 6, 2022, 10:21am UTC](https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352/1 "2022-06-06T10:21:47Z")

</div>

Hello! What is maximum number that can be used in randomSeed() in P5JS?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [June 6, 2022, 12:18pm UTC](https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352/2 "2022-06-06T12:18:31Z")

</div>

Hi @Nik,

The value is a 32bit unsigned integer, so …

> An unsigned integer is **a 32-bit datum that encodes a nonnegative integer in the range [0 to 4294967295]**

Cheers  
— mnse

**remark** : you can also put other values regarding the js Number specification, but interally it will be casted to unsigned 32bit integer 🙂

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 6, 2022, 12:29pm UTC](https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352/3 "2022-06-06T12:29:20Z")

</div>

The seed is stored by this “private” method below:

> <https://github.com/processing/p5.js/blob/v1.4.1/src/math/random.js#L31-L35>

Its comment states that `>>> 0` truncates the result to an unsigned 32-bit (4-byte) integer range, which is from 0 to 2\*\*32 - 1 or 4\_294\_967\_295 max.

You can read about the unsigned right shift operator on this link below:

> **[Unsigned right shift (\>\>\>) - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift)**
>
> The unsigned right shift operator (\>\>\>)
> (zero-fill right shift) shifts the first operand the specified number of bits to the
> right.

Here’s a shorter way to write `this[stateProperty] = (val == null ? Math.random() * m : val) >>> 0;` using the nullish coalescing operator `??`:

```javascript
this[stateProperty] = (val ?? Math.random() * m) >>> 0;

```

> **[Nullish coalescing operator (??) - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)**
>
> The nullish coalescing operator (??) is a logical
> operator that returns its right-hand side operand when its left-hand side operand is
> null or undefined, and otherwise returns its left-hand side
> operand.

---

<div class="post-metadata">

**Author:** ![Nik](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@Nik](https://discourse.processing.org/u/Nik)\
**Post date:** [June 6, 2022, 12:51pm UTC](https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352/4 "2022-06-06T12:51:39Z")

</div>

GoToLoop many thanks!
