Skip to content

Commit e61cbca

Browse files
committed
Fixed implicit long to double conversion warning.
error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808.
1 parent 9284453 commit e61cbca

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/njs_number.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#define _NJS_NUMBER_H_INCLUDED_
99

1010

11-
#define NJS_MAX_LENGTH (0x1fffffffffffffLL)
11+
#define NJS_MAX_LENGTH (0x1fffffffffffffLL)
12+
#define NJS_INT64_DBL_MIN (-9.223372036854776e+18) /* closest to INT64_MIN */
13+
#define NJS_INT64_DBL_MAX (9.223372036854776e+18) /* closest to INT64_MAX */
1214

1315

1416
double njs_key_to_index(const njs_value_t *value);
@@ -57,10 +59,10 @@ njs_inline int64_t
5759
njs_number_to_integer(double num)
5860
{
5961
if (njs_fast_path(!isnan(num))) {
60-
if (num < INT64_MIN) {
62+
if (num < NJS_INT64_DBL_MIN) {
6163
return INT64_MIN;
6264

63-
} else if (num > INT64_MAX) {
65+
} else if (num > NJS_INT64_DBL_MAX) {
6466
return INT64_MAX;
6567
}
6668

0 commit comments

Comments
 (0)