Skip to content

Commit 3b39a30

Browse files
committed
unit_evaluate_dbl: fixed err check
arm64 (Apple silicon) needs the comparison with NAN with isnan(). Fixes also failing test misc_test_unit_evaluate on GH macos-14 runner (arm64 mac),
1 parent 3b9f444 commit 3b39a30

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/misc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ unit_evaluate(const char *str, const char **endptr)
8080
{
8181
double ret = unit_evaluate_dbl(str, false, endptr);
8282

83-
if (ret == NAN || ret >= nexttoward((double) LLONG_MAX, LLONG_MAX)) {
83+
if (std::isnan(ret) ||
84+
ret >= nexttoward((double) LLONG_MAX, LLONG_MAX)) {
8485
return LLONG_MIN;
8586
}
8687

@@ -94,7 +95,7 @@ unit_evaluate(const char *str, const char **endptr)
9495
* @param case_sensitive should 'm' be considered as mega
9596
* @param endptr if not NULL, point to suffix after parse
9697
* @returns positive floating point representation of the string
97-
* @returns NAN if error
98+
* @returns NAN if error (isnan() must be called to check ret val)
9899
*/
99100
double
100101
unit_evaluate_dbl(const char *str, bool case_sensitive, const char **endptr)

0 commit comments

Comments
 (0)