Jon Blower wrote:
The netCDF file stored the depths as single-precision floats, and the
NetCDF-Java lib reads these floats and converts to double-precision
floats. If I would guess, that
appears to be the step that introduces the low bit errors in the values.
Hi Tim – yes, the conversion from 32- to 64- bit real numbers introduces
spurious precision. I think this is a general feature of digitised
floating-point numbers. In Java we don’t have to worry about zeroing
out arrays and such-like – memory is “safe”. We could ensure that the
numbers are only displayed to 32-bit precision even if they are 64-bit
internally – I’ve filed a “todo” for this
(http://www.resc.rdg.ac.uk/trac/ncWMS/ticket/184).
Cheers, Jon
generally its not possible to determine the underlying precision without breaking a lot of encapsulation. Probably most conversion in a cast, ie
float f = (float) d;
im not sure what the JLS (java language spec) says about that - it may be JVM
dependent.