use HUGE_VAL instead of DBL_MAX as inf