NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
The issue stems from the fact that Java stores float variables in binary and some values (like 0.2) can't be represented in binary. ncks always returns floats with 6 decimal places.
ncks -s '%f' -v VARIABLE NETCDF_FILE I got an equivalent output in Java doing the following: import java.math.BigDecimal; ... float var = ... // (Code to get variable into a Java float excluded) BigDecimal big_var = new BigDecimal(var); String ncks_formated_var = big_var.setScale(6,6).toString(); -- Kyle Wilcox NOAA Chesapeake Bay Office 410 Severn Avenue Suite 107A Annapolis, MD 21403 office: (410) 295-3151 Kyle.Wilcox@xxxxxxxx
netcdf-java
archives: