mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 17:40:50 +00:00
explicitly checks with ifdefs if our floating point and long long assumptions are verified
This commit is contained in:
parent
fe24458996
commit
88e8d89f1e
2
redis.c
2
redis.c
@ -3513,6 +3513,7 @@ static int rdbSaveDoubleValue(FILE *fp, double val) {
|
|||||||
len = 1;
|
len = 1;
|
||||||
buf[0] = (val < 0) ? 255 : 254;
|
buf[0] = (val < 0) ? 255 : 254;
|
||||||
} else {
|
} else {
|
||||||
|
#if (DBL_MANT_DIG >= 52) && (LLONG_MAX == 0x7fffffffffffffffLL)
|
||||||
/* Check if the float is in a safe range to be casted into a
|
/* Check if the float is in a safe range to be casted into a
|
||||||
* long long. We are assuming that long long is 64 bit here.
|
* long long. We are assuming that long long is 64 bit here.
|
||||||
* Also we are assuming that there are no implementations around where
|
* Also we are assuming that there are no implementations around where
|
||||||
@ -3527,6 +3528,7 @@ static int rdbSaveDoubleValue(FILE *fp, double val) {
|
|||||||
if (val > min && val < max && val == ((double)((long long)val)))
|
if (val > min && val < max && val == ((double)((long long)val)))
|
||||||
ll2string((char*)buf+1,sizeof(buf),(long long)val);
|
ll2string((char*)buf+1,sizeof(buf),(long long)val);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val);
|
snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val);
|
||||||
buf[0] = strlen((char*)buf+1);
|
buf[0] = strlen((char*)buf+1);
|
||||||
len = buf[0]+1;
|
len = buf[0]+1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user