[Avida-SVN] r1515 - development/source/main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Tue May 1 19:13:20 PDT 2007


Author: brysonda
Date: 2007-05-01 22:13:20 -0400 (Tue, 01 May 2007)
New Revision: 1515

Modified:
   development/source/main/cPopulation.cc
Log:
Change negative zero case handling to use integer comparison rather floating point. (not necessarily a fix for Intel macs)

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2007-05-02 01:54:38 UTC (rev 1514)
+++ development/source/main/cPopulation.cc	2007-05-02 02:13:20 UTC (rev 1515)
@@ -1643,7 +1643,7 @@
     //   to the output stage, but behavior is dependent on compiler used and optimization
     //   level.  For consistent output, ensures that 0.0 is returned.
     const double p = ((double) abundance) / (double) num_organisms;
-    const double partial_ent = (p == 1.0) ? 0.0 : -(p * Log(p)); 
+    const double partial_ent = (abundance == num_organisms) ? 0.0 : -(p * Log(p)); 
     entropy += partial_ent;
     
     // Do any special calculations for threshold genotypes.
@@ -1698,7 +1698,7 @@
     //   level.  For consistent output, ensures that 0.0 is returned.
     if (abundance > 0) {
       double p = ((double) abundance) / (double) num_organisms;
-      double partial_ent = (p == 1.0) ? 0.0 : -(p * Log(p));
+      double partial_ent = (abundance == num_organisms) ? 0.0 : -(p * Log(p));
       species_entropy += partial_ent;
     }
     




More information about the Avida-cvs mailing list