This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> > 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