Thread: another little program: is this correct?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Well, the random generator is very simple. For each second passed, the seed seems to grow exactly by one. Second, %d is for integers, not for time_ts. It might not be _very_ portable. The new scope.. I can't tell whether it's a good idea or not. It probably is. The algorithm is fine, as I'm using it, too.

  2. #2
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    Note that "0u - 1 + 0.0" is a complicated way of saying "(double)UINT_MAX". It has the disadvantage of yielding undefined behavior, as the value of "0u - 1" is not defined.

    The binary search implementation looks ok at first sight.

    Quote Originally Posted by Brafil View Post
    For each second passed, the seed seems to grow exactly by one.
    If time_t happens to be an integral type of size > sizeof(unsigned int), the seed grows by one every two seconds.

    Greets,
    Philip
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with my program, please take a look
    By Hermisky in forum C++ Programming
    Replies: 2
    Last Post: 02-02-2006, 10:13 AM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 07:51 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM