mirror of
https://github.com/fluencelabs/redis
synced 2025-06-19 04:01:22 +00:00
Fix HINCRBYFLOAT to work with long doubles.
During the refactoring needed for lazy free, specifically the conversion of t_hash from struct robj to plain SDS strings, HINCRBFLOAT was accidentally moved away from long doubles to doubles for internal processing of increments and formatting. The diminished precision created more obvious artifacts in the way small numbers are formatted once we convert from decimal number in radix 10 to double and back to its string in radix 10. By using more precision, we now have less surprising results at least with small numbers like "1.23", exactly like in the previous versions of Redis. See issue #2846.
This commit is contained in:
@ -426,9 +426,9 @@ int string2l(const char *s, size_t slen, long *lval) {
|
||||
* Note that this function demands that the string strictly represents
|
||||
* a double: no spaces or other characters before or after the string
|
||||
* representing the number are accepted. */
|
||||
int string2d(const char *s, size_t slen, double *dp) {
|
||||
int string2ld(const char *s, size_t slen, long double *dp) {
|
||||
char buf[256];
|
||||
double value;
|
||||
long double value;
|
||||
char *eptr;
|
||||
|
||||
if (slen >= sizeof(buf)) return 0;
|
||||
@ -436,7 +436,7 @@ int string2d(const char *s, size_t slen, double *dp) {
|
||||
buf[slen] = '\0';
|
||||
|
||||
errno = 0;
|
||||
value = strtod(buf, &eptr);
|
||||
value = strtold(buf, &eptr);
|
||||
if (isspace(buf[0]) || eptr[0] != '\0' ||
|
||||
(errno == ERANGE &&
|
||||
(value == HUGE_VAL || value == -HUGE_VAL || value == 0)) ||
|
||||
|
Reference in New Issue
Block a user