Ping Re: Make strtod respect the rounding mode (bug 14518)

Richard Henderson rth@twiddle.net
Wed Sep 12 02:56:00 GMT 2012


On 2012-09-11 14:25, Joseph S. Myers wrote:
> +/* Internal type for floating-point rounding modes.  */
> +typedef enum
> +{
> +  round_downward,
> +  round_tonearest,
> +  round_towardzero,
> +  round_upward
> +} rounding_mode_t;

Is there a good reason why you're defining a new enumeration instead
of letting the arch-specific header either (1) include bits/fenv.h,
or (2) define some other names that are bit-compatible with what comes
out of the fpu?

I'm not a fan of cookie-cutter translations like this:

> +    switch (fc & FE_TOWARDZERO)
> +	{
> +	case FE_DOWNWARD:
> +	  return round_downward;
> +
> +	case FE_TONEAREST:
> +	  return round_tonearest;
> +
> +	case FE_TOWARDZERO:
> +	  return round_towardzero;
> +
> +	case FE_UPWARD:
> +	  return round_upward;
> +
> +	default:
> +	  abort ();
> +	}

The substance in strtod_l.c and the associated test looks good.


r~



More information about the Libc-alpha mailing list