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 <sundbcn@gmail.com>
This commit is contained in:
Binbin 2022-04-18 13:34:22 +08:00 committed by GitHub
parent 0c4733c8d7
commit fe4b4806b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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) {