Regarding truncation of Values in HDF-5

hi… i am writing a HDF-5 file. In this file i am writing a dataset which has float datatype. I have populated the value of this particular dataset as 10e06. while verifiying in HDF5 Viewer i found that it is showing the value as 9.9999999999e06. This happened with other datasets too. In same cases the values get truncated on their own when using HDF-View or h5dump.
Can somebody tell how to resolve this issue of values getting changed while writing in HDF-5.
Thanks in advance

Which platform? Which version of HDFView? Which version of HDF5? G.

Platform: Red Hat Linux Server 7.6
HDF5 View Version : 3.1.0
Version of HDF5 : Version 1.8.17
Does it also effect the precision and truncation issue?
don’t mind my basic questions, i am new to HDF5

There are different layers in play here, what’s stored in the file, and how it’s rendered downstream.

Can you send us the h5dump output of that dataset, e.g., h5dump -d <dataset path> <file name>?

I suspect this is a bug/artifact that arises somewhere in the (Java-)conversion from floating-point numbers to strings. Do you have a sample program to reproduce the issue/generate the data?
Can you try a newer version of HDFView, e.g., 3.1.4?

G.

If you would like to diagnose before upgrading, then notice that your intended value of 10e06 is a valid code point in data type float. However, 9.9999999999e06, AKA 9999999.9999, is NOT a valid code point. The adjacent code points in 32-bit floats are exactly 9999999.000 and 10000000.000. Nothing in between is possible in this data type.

This by itself suggests one of two possibilities. (1) Your files contain the intended values, and there is a display bug in your older version of HDF5 Viewer, or its supporting libraries; as Gerd already suggested. Or (2) your data type is actually double, not float; and somehow you have managed to store values extremely close to 9.9999999999e06.

So display a few values using something other than HDF5 View. I suggest h5dump -d as already suggested; or directly from C, or your favorite programming language. Show at least 11 significant digits, and also double check your data type.

2 Likes