mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
2f822ec0dc
commit
162d674c5b
1 changed files with 2 additions and 3 deletions
|
@ -273,7 +273,7 @@ static enum number_type parse_float(const char *buffer, double *res, const char
|
||||||
if (errno || *endp == buffer)
|
if (errno || *endp == buffer)
|
||||||
return NEITHER;
|
return NEITHER;
|
||||||
if (**endp == ',') {
|
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
|
/* 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
|
* as this is likely indication of a bug - but right now we don't have
|
||||||
* that information available */
|
* that information available */
|
||||||
|
@ -594,8 +594,7 @@ static void fahrenheit(char *buffer, void *_temperature)
|
||||||
|
|
||||||
switch (integer_or_float(buffer, &val)) {
|
switch (integer_or_float(buffer, &val)) {
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
/* Floating point equality is evil, but works for small integers */
|
if (IS_FP_SAME(val.fp, 32.0))
|
||||||
if (val.fp == 32.0)
|
|
||||||
break;
|
break;
|
||||||
if (val.fp < 32.0)
|
if (val.fp < 32.0)
|
||||||
temperature->mkelvin = C_to_mkelvin(val.fp);
|
temperature->mkelvin = C_to_mkelvin(val.fp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue