From fe4b4806b3f39256a82020a1cd2e832ebabc2ef9 Mon Sep 17 00:00:00 2001 From: Binbin Date: Mon, 18 Apr 2022 13:34:22 +0800 Subject: [PATCH] Fix long long to double implicit conversion warning (#10595) There is a implicit conversion warning in clang: ``` util.c:574:23: error: implicit conversion from 'long long' to 'double' changes value from -4611686018427387903 to -4611686018427387904 [-Werror,-Wimplicit-const-int-float-conversion] if (d < -LLONG_MAX/2 || d > LLONG_MAX/2) ``` introduced in #10486 Co-authored-by: sundb --- src/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index ae1f89b65a..85b631f193 100644 --- a/src/util.c +++ b/src/util.c @@ -571,7 +571,7 @@ int double2ll(double d, long long *out) { * i.e. all double values in that range are representable as a long without precision loss, * but not all long values in that range can be represented as a double. * we only care about the first part here. */ - if (d < -LLONG_MAX/2 || d > LLONG_MAX/2) + if (d < (double)(-LLONG_MAX/2) || d > (double)(LLONG_MAX/2)) return 0; long long ll = d; if (ll == d) {