aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-01-21 22:03:08 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-21 14:11:52 -0800
commit162d674c5b769293d7f898ba28592afad705f1a3 (patch)
treee9cb8a980cbb0e4f91237bfd935a218588492b3e
parent2f822ec0dcd2d715bf4234023b510aed9fe90f0b (diff)
downloadsubsurface-162d674c5b769293d7f898ba28592afad705f1a3.tar.gz
Don't compare floats for equality
Now that we have a macro to replace float equality testing, we should use it in places where floating point jitter might bite use otherwise. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--parse-xml.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 3e320c9f3..56bfc0996 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -273,7 +273,7 @@ static enum number_type parse_float(const char *buffer, double *res, const char
if (errno || *endp == buffer)
return NEITHER;
if (**endp == ',') {
- if (val == rint(val)) {
+ if (IS_FP_SAME(val, rint(val))) {
/* we really want to send an error if this is a Subsurface native file
* as this is likely indication of a bug - but right now we don't have
* that information available */
@@ -594,8 +594,7 @@ static void fahrenheit(char *buffer, void *_temperature)
switch (integer_or_float(buffer, &val)) {
case FLOAT:
- /* Floating point equality is evil, but works for small integers */
- if (val.fp == 32.0)
+ if (IS_FP_SAME(val.fp, 32.0))
break;
if (val.fp < 32.0)
temperature->mkelvin = C_to_mkelvin(val.fp);