[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25557: Documentation of format doesn't describe "g" accurately
From: |
Eli Zaretskii |
Subject: |
bug#25557: Documentation of format doesn't describe "g" accurately |
Date: |
Sat, 28 Jan 2017 17:23:55 +0200 |
> Cc: 25557-done@debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel@live.com>
> Date: Sat, 28 Jan 2017 10:04:33 -0500
>
> >> On a related note, is there a way to get a shortest representation of a
> >> number? Something like %g, but without exponents.
> >
> > Sorry, I don't understand the question. How can you represent an
> > arbitrary number without exponents at all, except by %f?
>
> I'd like something like this (with a hypothetical %q):
>
> (format "%.3q" 3) ⇒ "3"
> (format "%.3q" 3.00) ⇒ "3"
> (format "%.3q" 3.30) ⇒ "3.3"
> (format "%.3q" 3.05) ⇒ "3.05"
> (format "%.3q" 3.352) ⇒ "3.35"
> (format "%.3q" 3100000) ⇒ "3100000"
>
> This is in fact just the same as 'g', except for the last entry (%g produces
> "3.1e+06"). Is this achievable?
Yes, if you use "%.7g". In general, use "%.Ng" if you want up to N
digits in the printed representation.
Does that answer your question?
- bug#25557: Documentation of format doesn't describe "g" accurately, Clément Pit--Claudel, 2017/01/27
- bug#25557: Documentation of format doesn't describe "g" accurately, Eli Zaretskii, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Clément Pit--Claudel, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately,
Eli Zaretskii <=
- bug#25557: Documentation of format doesn't describe "g" accurately, Clément Pit--Claudel, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Eli Zaretskii, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Clément Pit--Claudel, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Eli Zaretskii, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Clément Pit--Claudel, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Eli Zaretskii, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Clément Pit--Claudel, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Eli Zaretskii, 2017/01/28
- bug#25557: Documentation of format doesn't describe "g" accurately, Clément Pit--Claudel, 2017/01/28