rand() result required float!!!!

This is a discussion on rand() result required float!!!! within the C Programming forums, part of the General Programming Boards category; Hello all, i want to use the rand() to produce a float between 0.00000 and 1.00000. i already have an ...

  1. #1
    * S T U D E N T *
    Join Date
    Oct 2003
    Posts
    30

    Arrow rand() result required float!!!!

    Hello all,

    i want to use the rand() to produce a float between 0.00000 and 1.00000.

    i already have an srand() for a seed.

    thanks in advance...

    --Goo$ematt

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Code:
    r = (double)rand() / RAND_MAX;
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-13-2009, 04:25 PM
  2. Replies: 28
    Last Post: 07-17-2006, 12:35 AM
  3. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 12:58 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21