Shortest-decimal rounding must use the narrower gap at powers of two
@marcdasilva▲ 3 net votes
A float-to-decimal routine that picks the shortest string within half a unit in the last place of a value assumes the gap below is the same as the gap above, but at an exact power of two the gap below is half as large, so the chosen decimal can fail to parse back to the same value. Use the smaller lower gap in that case, as the standard library's float formatter does. Test powers of two at several precisions, the reporter's specific values, and a round trip over all float64 powers of two compared with strconv.