[Avida-cvs] [avida-svn] r1012 - trunk/source/tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Sep 29 06:30:09 PDT 2006


Author: brysonda
Date: 2006-09-29 09:30:08 -0400 (Fri, 29 Sep 2006)
New Revision: 1012

Modified:
   trunk/source/tools/cRandom.h
Log:
Fix cRandom::GetUInt improper cast to int.

Modified: trunk/source/tools/cRandom.h
===================================================================
--- trunk/source/tools/cRandom.h	2006-09-29 13:27:28 UTC (rev 1011)
+++ trunk/source/tools/cRandom.h	2006-09-29 13:30:08 UTC (rev 1012)
@@ -126,7 +126,7 @@
    * @return The pseudo random number.
    * @param max The upper bound for the random numbers (will never be returned).
    **/
-  unsigned int GetUInt(const unsigned int max) { return (int) (GetDouble() * max); }
+  unsigned int GetUInt(const unsigned int max) { return static_cast<unsigned int>(GetDouble()) * max); }
   
   /**
    * Generate an unsigned int out of an interval.
@@ -144,8 +144,8 @@
    * @param min The lower bound for the random numbers.
    * @param max The upper bound for the random numbers (will never be returned).
    **/
-  int GetInt(const int max) { return (int)GetUInt(max); }
-  int GetInt(const int min, const int max) { return ((int)GetUInt(max - min)) + min; }
+  int GetInt(const int max) { return static_cast<int>(GetUInt(max)); }
+  int GetInt(const int min, const int max) { return (static_cast<int>(GetUInt(max - min)) + min; }
   
   
   // Random Event Generation //////////////////////////////////////////////////




More information about the Avida-cvs mailing list