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] Convert e_exp2l.c into a template


On Tue, 16 May 2017, Gabriel F. T. Gomes wrote:

>  # define LDBL_EPSILON 0x1p-106L
>  #endif

This should be removed, as the definition of M_EPSILON in 
sysdeps/generic/math-type-macros.h handles it.

> +#define M_PRE_X(prefix, x) prefix ## _ ## x
> +#define M_PRE_S(prefix, x) M_PRE_X (prefix, x)
> +#define M_PRE(x) M_PRE_S (M_PFX, x)

This should not be needed.  Just use M_MAX_EXP, M_MANT_DIG, etc. (adding 
new macros such as M_MIN_EXP to sysdeps/generic/math-type-macros.h as 
needed).

> +	  FLOAT fractx = x - intx;
> +	  FLOAT result;
> +	  if (M_SUF (fabs) (fractx) < M_PRE (EPSILON) / M_LIT (4.0))
> +	    result = M_SUF (__scalbn) (M_LIT (1.0) + fractx, intx);

And I think it's best just to use integers 4 and 1 here, as in other 
templates, and rely on implicit conversions, to make the code less 
verbose.

> -	    result = __scalbnl (__ieee754_expl (M_LN2l * fractx), intx);
> +	    result = M_SUF (__scalbn) (M_SUF (__ieee754_exp) (M_SUF (M_LN2)
> +							      * fractx), intx);

Use M_EXP and M_SCALBN, since they exist.

-- 
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]