On Tue, Dec 06, 2022 at 12:21:11PM +0100, Theo Buehler wrote: > On Tue, Dec 06, 2022 at 12:01:57PM +0100, Claudio Jeker wrote: > > Printing timestamps is rather common thing in OpenMetrics so add a native > > function for this. The benefit is that it prints the timestamp as pseudo > > float with higher precision than a regular float. > > This part makes sense to me and is ok > > > Also adjust output of doubles to include enough significant digits to > > print the value in full precision. > > Not sure. %.17g seems too much as things with reasonable precision like > f = 0.1 will now be printed as > > 0.10000000000000001, > > which is wrong. If you think the default .6 is not enough and want to > crank the precision to .9 or even .12, I'm ok with that (I'd keep it > at a multiple of 3). >
I skipped this part for now. I agree that %.17g is too extrem but it was mentioned in the OpenMetrics draft that it should be used in printf calls from C to get full precision. Since nothing uses floats right now I left this as is and will reconsider once we actually use the float format. I got burned by this when I tried to print timestamps using floats but implementing the ometric_set_timeval() function worked around this in a better way. -- :wq Claudio