• antirez's avatar
    Make sure that ZADD can accept the full range of double values. · 9d520a7f
    antirez authored
    This fixes issue #1194, that contains many details.
    
    However in short, it was possible for ZADD to not accept as score values
    that was however possible to obtain with multiple calls to ZINCRBY, like
    in the following example:
    
    redis 127.0.0.1:6379> zadd k 2.5e-308 m
    (integer) 1
    redis 127.0.0.1:6379> zincrby k -2.4e-308 m
    "9.9999999999999694e-310"
    redis 127.0.0.1:6379> zscore k m
    "9.9999999999999694e-310"
    redis 127.0.0.1:6379> zadd k 9.9999999999999694e-310 m1
    (error) ERR value is not a valid float
    
    The problem was due to strtod() returning ERANGE in the following case
    specified by POSIX:
    
    "If the correct value would cause an underflow, a value whose magnitude
    is no greater than the smallest normalized positive number in the return
    type shall be returned and errno set to [ERANGE].".
    
    Now instead the returned value is accepted even when ERANGE is returned
    as long as the return value of the function is not negative or positive
    HUGE_VAL or zero.
    9d520a7f
object.c 18.5 KB