random probs

This is a discussion on random probs within the Windows Programming forums, part of the Platform Specific Boards category; Hi I have a program which made use of some of the UNIX rand48 functions to give me random doubles. ...

  1. #1
    tuckster
    Guest

    random probs

    Hi

    I have a program which made use of some of the UNIX rand48 functions to give me random doubles. I have to port the code to NT and realised that I only have rand at my disposal. Does anyone have any eat routes for generating random fp values?

    Thanks

    Tucky

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    use rand() to get a random int. Divide that by the constant RAND_MAX to get a random float or double.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    tuckster
    Guest
    Simple as that!

    Many thanks!

    tucky

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random to int?
    By psyadam in forum C# Programming
    Replies: 7
    Last Post: 07-22-2008, 09:09 PM
  2. Lesson #3 - Math
    By oval in forum C# Programming
    Replies: 2
    Last Post: 04-27-2006, 09:16 AM
  3. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  4. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 03:40 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 05:11 PM

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