pub fn write_g17(buf: &mut [u8; 32], d: f64) -> &[u8] ⓘExpand description
Writes a double the way C’s %.17g writes one, which is what AROP
replies with.
Redis formats an aggregate through ld2string in its automatic mode, and
that mode is a plain %.17Lg, so this is the one reply in the whole server
that is not a shortest round trip printer. The difference is visible: three
tenths comes back as 0.29999999999999999 here and as 0.3 from ZSCORE,
because seventeen significant digits of the nearest double to three tenths
really are those.
%g picks between the two forms the way C says: the exponent form when the
decimal exponent is below minus four or at least the precision, the plain
form otherwise, and trailing zeros come off either way.