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: Expected behaviour with precision on floating point number #54

Closed bjet007 closed 3 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

sbinet commented 4 years ago

hi,

thanks for the report (and your interest in astrogo). your suggestion sounds good to me.

do you want to send a PR fixing this oversight?

sbinet commented 3 years ago

fixed w #57.