math.random question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: math.random question

  1. #1
    Join Date
    Jul 2005
    Posts
    2

    Math.random newbie question

    I am in a beginning javascript class. I understand this is a total newbie question and I appologize in advance.

    My textbook states that Math.random will generate a random number between 0 and 1. Does this INCLUDE 0 and 1? I am getting a feeling from my results that it does.

    Thank you for your time and responses,

    Robin
    Last edited by buymysoul; 07-15-2005 at 02:25 PM. Reason: change title

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    I don't know about javascript.

    There are many javascript tutorials or help sites on the web, including w3schools.com.

    Java's Math.random() method will generate random numbers "greater than or equal to 0.0 and less than 1.0" (per the API documentation).

    My guess is that javascript handles the random function in the same way.
    Last edited by nspils; 07-15-2005 at 08:08 PM.

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    According to O'Reilly "JavaScript - The Definitive Guide" Math.random() returns
    A pseudo-random number between 0.0 and 1.0
    eschew obfuscation

  4. #4
    Join Date
    Jul 2005
    Posts
    2
    Hey thanks guys, I guess the anomolie I experienced had to do with something else.

    Thanks a lot for your help.

    Robin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center