fn format_g(v: f64, prec: usize, upper: bool) -> String
Format using %g/%G: use shorter of %f and %e, removing trailing zeros.