Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:21:35+00:00 2026-06-05T18:21:35+00:00

For this piece of script: var die = Math.floor(Math.random()*6 + 1); It’s expected to

  • 0

For this piece of script:

var die = Math.floor(Math.random()*6 + 1);

It’s expected to generate a random number between 1 to 6.

The die number 6 before rounded floor is 6.0 to 6.999…999

However, the die number 1 before rounded floor is 1.00…001 to 1.99…999


Plus, because it is (random_nummber * 6) (“carry” in number system?)

Is it possible that number of generated in (1 to 1.9999) is different to (2 to 2.999)?

(possible the difference is 1)


Is this substantial/acceptable in real world? e.g. to fairly pick a customer for jack-pop. OR calculate possibility in gambling.

Or, did I do something wrong?

p.s. I’m not a math/science student, so I may miss a lot of math concepts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:21:37+00:00Added an answer on June 5, 2026 at 6:21 pm

    The Math.random() implementations in firefox and google chrome are pretty bad when it comes to uniform distribution (have not tested IE or others). You can easily roll your own that’s better.

    Here you can test them: https://web.archive.org/web/20150905080518/http://www.merlyn.demon.co.uk/js-randm.htm#TRFP

    Here’s something to read: https://web.archive.org/web/20120502223108/http://baagoe.com/en/RandomMusings/javascript/

    Here’s also a jsfiddle http://jsfiddle.net/mVrdE/2/ which runs 20 tests of 1 million coin flips for each method. Results for windows google chrome:

    Math.random() min bias: 2 max bias: 1270 
    rand() min bias: 2 max bias: 15
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of code like this - <script> var x,m,cloneNodex; function addVtier()
I've found this piece in a script var name = project.SMALL_WIDTH//p.containerWidth() /// 2//project.WIDTH /
If I add this piece of html to my page: <script type=text/javascript> var s
In javascript suppose you have this piece of code: <div> <script type=text/javascript>var output =
I have this piece of javascript: <script type=text/javascript> function show_confirm() { var type =
I have this piece of code: <textarea id=test style=width: 400px; height: 100px></textarea> <script> var
I'm trying to get this piece of script to work, but it keeps dying
I've got this piece of code in my jquery validation script: resetForm: function() {
This piece of code compiles and runs as expected on GCC 3.x and 4.x:
I have problem with this piece of code: var el = $('div#editor'); el.find('*[contentEditable]').removeAttr('contentEditable'); It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.