Index: trunk/ppSim/src/ppSimInsertGalaxies.c
===================================================================
--- trunk/ppSim/src/ppSimInsertGalaxies.c	(revision 32350)
+++ trunk/ppSim/src/ppSimInsertGalaxies.c	(revision 34083)
@@ -2,6 +2,9 @@
 static char *defaultModel = "PS_MODEL_SERSIC";
 
-float imageSum (psImage *image) {
-    float sum = 0.0;
+// this is used to measure the inserted flux as a difference of 2 large numbers : must use
+// 'double' or we get floating point errors and trends on a scale of ~0.005 mags at > -10 mags
+// instrumental
+double imageSum (psImage *image) {
+    double sum = 0.0;
     for (int iy = 0; iy < image->numRows; iy++) {
 	for (int ix = 0; ix < image->numCols; ix++) {
@@ -165,7 +168,7 @@
 	
 	// insert the source flux in the image
-	float sum1 = imageSum(source->pixels);
+	double sum1 = imageSum(source->pixels);
 	pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
-	float sum2 = imageSum(source->pixels);
+	double sum2 = imageSum(source->pixels);
 	float flux = sum2 - sum1;
 
