diff options
-rw-r--r-- | converter/other/fitstopnm.c | 8 | ||||
-rw-r--r-- | doc/HISTORY | 2 | ||||
-rw-r--r-- | lib/util/pm_c_util.h | 5 |
3 files changed, 13 insertions, 2 deletions
diff --git a/converter/other/fitstopnm.c b/converter/other/fitstopnm.c index 0a1f899b..181a85ce 100644 --- a/converter/other/fitstopnm.c +++ b/converter/other/fitstopnm.c @@ -468,6 +468,9 @@ scanImageForMinMax(FILE * const ifP, double * const dataminP, double * const datamaxP) { + /* Note that a value in the file might be Not-A-Number. We ignore + such entries in computing the minimum and maximum for the image. + */ double dmax, dmin; unsigned int image; pm_filepos rasterPos; @@ -495,8 +498,9 @@ scanImageForMinMax(FILE * const ifP, double val; readVal(ifP, valFmt, &val); if (image == imagenum || multiplane ) { - dmax = MAX(dmax, val); - dmin = MIN(dmin, val); + /* Note: if 'val' is NaN, result is 2nd operand */ + dmax = MAX(val, dmax); + dmin = MIN(val, dmin); } } } diff --git a/doc/HISTORY b/doc/HISTORY index 6096041f..2ce2af00 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -6,6 +6,8 @@ CHANGE HISTORY Not yet BJH Release 10.53.00 + fitstopnm: Deal properly with NaN in input image. + pamstereogram: Add mapped texture stereogram option. Thanks Scott Pakin. diff --git a/lib/util/pm_c_util.h b/lib/util/pm_c_util.h index 07913f30..f17d1e03 100644 --- a/lib/util/pm_c_util.h +++ b/lib/util/pm_c_util.h @@ -1,6 +1,11 @@ #ifndef PM_C_UTIL_INCLUDED #define PM_C_UTIL_INCLUDED +/* Note that for MAX and MIN, if either of the operands is a floating point + Not-A-Number, the result is the second operand. So if you're computing a + running maximum and want to ignore the NaNs in the computation, put the + running maximum variable second. +*/ #undef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) #undef MIN |