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.

Re: [thredds] Incorrect values for elevation (WMS) [SEC=UNCLASSIFIED]

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.



  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the thredds archives: