From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25557: Documentation of format doesn't describe "g" accurately Date: Sat, 28 Jan 2017 17:23:55 +0200 Message-ID: <83a8abyzqs.fsf@gnu.org> References: <78ace0d5-59f1-0d7d-1f0e-b589a947d76c@live.com> <83poj7zika.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1485617118 21538 195.159.176.226 (28 Jan 2017 15:25:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 28 Jan 2017 15:25:18 +0000 (UTC) Cc: 25557@debbugs.gnu.org To: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 28 16:25:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXUsH-0004ne-RQ for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Jan 2017 16:25:10 +0100 Original-Received: from localhost ([::1]:52249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXUsL-0002nL-Pr for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Jan 2017 10:25:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXUsD-0002m6-HB for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 10:25:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXUsA-000110-DU for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 10:25:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51093) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cXUsA-00010u-9w for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 10:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cXUsA-00021k-4Z for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 10:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Jan 2017 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25557 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25557-submit@debbugs.gnu.org id=B25557.14856170587735 (code B ref 25557); Sat, 28 Jan 2017 15:25:02 +0000 Original-Received: (at 25557) by debbugs.gnu.org; 28 Jan 2017 15:24:18 +0000 Original-Received: from localhost ([127.0.0.1]:49292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXUrR-00020g-Sf for submit@debbugs.gnu.org; Sat, 28 Jan 2017 10:24:18 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXUrQ-00020T-66 for 25557@debbugs.gnu.org; Sat, 28 Jan 2017 10:24:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXUrH-0000dI-J4 for 25557@debbugs.gnu.org; Sat, 28 Jan 2017 10:24:10 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXUrH-0000dD-Ft; Sat, 28 Jan 2017 10:24:07 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2053 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cXUrG-0005KW-9A; Sat, 28 Jan 2017 10:24:07 -0500 In-reply-to: (message from =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel on Sat, 28 Jan 2017 10:04:33 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:128720 Archived-At: > Cc: 25557-done@debbugs.gnu.org > From: Clément Pit--Claudel > 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?