Randomizing

This is a discussion on Randomizing within the C++ Programming forums, part of the General Programming Boards category; >>Why doesn't the standard require everyone to use one algorithm that is determined the best? The standard doesn't require certain ...

  1. #16
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    >>Why doesn't the standard require everyone to use one algorithm that is determined the best?
    The standard doesn't require certain algorithms so that the compiler can use an algorithm that works best for the hardware. Speed is good, so the C++ standard is intentionally vague when it comes to stuff like that.

    >> I always thought the point of having a standard was to make things standard.
    Using the modulus or division to get a range from rand() has nothing to do with the standard, its a technique, not a language feature. :-)
    *Cela*

  2. #17
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Originally posted by Cela
    >> I always thought the point of having a standard was to make things standard.
    Using the modulus or division to get a range from rand() has nothing to do with the standard, its a technique, not a language feature. :-)
    Why doesn't the standard library have a function that will return a random number within certain limits? That would solve this problem, wouldn't it? Something like:
    Code:
    int spiffy_rand(int low, int high);
    Okay, maybe that identifier could use some work, but I think you get the idea.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  3. #18
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    >>Why doesn't the standard library have a function that will return a random number within certain limits?
    They have their reasons I guess, but it could be that it's simple enough to write one. And if you really need it, you probably know enough to write a good one. :-)
    *Cela*

  4. #19
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146

    Smile

    Thanks Cela for all of your help. Sorry if my posts were annoying. I'm just trying to learn more. Once again, thanks
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Randomizing dealing program C
    By BSmith4740 in forum C Programming
    Replies: 2
    Last Post: 08-04-2008, 02:42 PM
  2. randomizing
    By zanderela in forum C Programming
    Replies: 2
    Last Post: 03-21-2008, 02:54 AM
  3. Randomizing link list.
    By Axel in forum C Programming
    Replies: 4
    Last Post: 10-24-2005, 11:03 AM
  4. srand() not randomizing me?!
    By crummy in forum C Programming
    Replies: 3
    Last Post: 02-11-2005, 07:23 PM
  5. randomizing?
    By cerin in forum C++ Programming
    Replies: 55
    Last Post: 02-03-2005, 06:58 PM

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