astrogo / fitsio

fitsio is a pure-Go package to read and write `FITS` files
BSD 3-Clause "New" or "Revised" License
53 stars 24 forks source link

fitsio: Precision lost when writing small float64 value in the header #55

Closed bjet007 closed 4 years ago

bjet007 commented 4 years ago

Hi,

I'm trying to generate a fits file float64 value in the header. Since most of my values are small number with a lot of precision, decimal get truncated because of the way the float64 get printed in the document using %20f.

Looking at the specification (https://fits.gsfc.nasa.gov/standard40/fits_standard40aa-le.pdf), the limitation is on the number of bytes used, so I was expecting that I get the same value that I've specified in my go program.

Is it possible that the writer should use %20g instead of %20f so that value don't lose precision if value fit within the length of the spec.

I've create a small sample here to show the behaviour https://play.golang.org/p/oqFmTQBeNOD

bjet007 commented 4 years ago

duplicate du to github submit error.