[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ... Rounding
- Subject: Re: ... Rounding
- Date: Tue, 22 Oct 1996 13:40:19 -0600
> > Now another netcdf-3 matter. Conversions from float/double to other types
> > currently truncate rather than round. I favour rounding. If you decide
> > against this you should make it clear in the User's Guide that it is the
> > user's responsibility to round (if required).
>
> The interface for setting it doesn't seem to be standardized.
> See 'man ieee_flags' on a SunOS 5. On SGI's, the interface
> is fpsetround(), fpgetround(), in <ieeefp.h>.
>
> The user's guide should probably mention that the netcdf library doesn't
> mess with whatever rounding is in scope.
No, I don't think the IEEE rounding mode has anything to do with this
issue, it merely deals with rounding or truncation of the results of
floating-point operations or converting large integers to floats that
can't represent them precisely.
C and FORTRAN both require truncation toward zero for floating point to
integral conversions. The current rounding mode has no effect on these
conversions.
This behavior is well defined and, I think, well understood by C and
FORTRAN programmers, and netCDF preserves this conversion behavior. The
netCDF behavior is easy to explain, since it's the same as if a variable
of the source type is assigned to a variable of the destination type
with an assignment statement in either C or FORTRAN. Using rounding
instead would be unexpected.
But I think you're absolutely right that this should be mentioned
prominently in the User's Guide, and I'll see that it is.
--Russ