2 Replies - 180 Views - Last Post: 04 November 2019 - 09:30 AM

#1 goofyfoot   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-November 19

Math.random value

Posted 04 November 2019 - 09:06 AM

Hello All, just a simple question about the value produced each time it is run. Will it always be below 1.0, I have done document.write(Math.random));. 25 times in a row and all the results are 0.93748 / 0.254752 and so on. Not one result 1. anything.

Just wondering if its value will always be below zero. Thanks in advance for your help.
Is This A Good Question/Topic? 0
  • +

Replies To: Math.random value

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15427
  • View blog
  • Posts: 61,808
  • Joined: 12-June 08

Re: Math.random value

Posted 04 November 2019 - 09:19 AM

Check the docs.

Quote

The Math.random() function returns a floating-point, pseudo-random number in the range 01 (inclusive of 0, but not 1) with approximately uniform distribution over that range

https://developer.mo...cts/Math/random
Was This Post Helpful? 0
  • +
  • -

#3 goofyfoot   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-November 19

Re: Math.random value

Posted 04 November 2019 - 09:30 AM

https://developer.mozilla.org/en-US/

Thanks for your time and help. Should have looked in docs but being new to this. Needed to find a community forum anyhow.
Knowing it will never equal or exceed 1 is what I needed to know.
Have an idea for game stuff and it will come in handy. Thank you very much.......
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1