diff --git a/mongoose.c b/mongoose.c index 873ce1bd..206b5b31 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3973,7 +3973,7 @@ void mg_sntp_request(struct mg_connection *c) { double frac = ((double) (now % 1000)) / 1000.0; buf[0] = (0 << 6) | (4 << 3) | 3; t[0] = mg_htonl((uint32_t) (now / 1000) + SNTP_TIME_OFFSET); - t[1] = mg_htonl((uint32_t) ((uint32_t) (frac * SNTP_MAX_FRAC))); + t[1] = mg_htonl((uint32_t) ((int32_t) (frac * SNTP_MAX_FRAC))); mg_send(c, buf, sizeof(buf)); } } diff --git a/src/sntp.c b/src/sntp.c index 86bc4d6f..4f4dff1b 100644 --- a/src/sntp.c +++ b/src/sntp.c @@ -65,7 +65,7 @@ void mg_sntp_request(struct mg_connection *c) { double frac = ((double) (now % 1000)) / 1000.0; buf[0] = (0 << 6) | (4 << 3) | 3; t[0] = mg_htonl((uint32_t) (now / 1000) + SNTP_TIME_OFFSET); - t[1] = mg_htonl((uint32_t) ((uint32_t) (frac * SNTP_MAX_FRAC))); + t[1] = mg_htonl((uint32_t) ((int32_t) (frac * SNTP_MAX_FRAC))); mg_send(c, buf, sizeof(buf)); } }