This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] BZ#15536: Fix ulp(0x0.0p0) for 128-bit IBM long double.


On Fri, 31 May 2013, Carlos O'Donell wrote:

> @@ -269,8 +269,8 @@ static FLOAT max_error, real_max_error, imag_max_error;
>  
>  #define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1),  \
>                          (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
> -#define MAX_EXP CHOOSE ((LDBL_MAX_EXP-1), (DBL_MAX_EXP-1), (FLT_MAX_EXP-1),    \
> -                       (LDBL_MAX_EXP-1), (DBL_MAX_EXP-1), (FLT_MAX_EXP-1))
> +#define MIN_EXP CHOOSE ((LDBL_MIN_EXP), (DBL_MIN_EXP), (FLT_MIN_EXP),  \
> +                       (LDBL_MIN_EXP), (DBL_MIN_EXP), (FLT_MIN_EXP))
>  
>  /* Compare KEY (a string, with the name of a test or a function) with
>     ULP (a pointer to a struct ulp_data structure), returning a value
> @@ -680,7 +680,7 @@ ulp (FLOAT value)
>         /* Fall through...  */
>        case FP_SUBNORMAL:
>          /* The next closest subnormal value is a constant distance away.  */
> -       ulp = FUNC(ldexp) (1.0, 1 - (MAX_EXP + MANT_DIG));
> +       ulp = FUNC(ldexp) (1.0, MIN_EXP - MANT_DIG);

You have an off-by-one error here, so this would give e.g. 0x1p-1073 not 
0x1p-1074 for double.

(The confusing semantics of the ISO C <float.h> macros don't particularly 
help, but it's worse when the macros in libm-test.inc mysteriously 
subtract 1 so their semantics are different from the ISO C semantics, and 
even worse when some macros but not others subtract 1.)

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]