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 10:37:25 +0200 Message-ID: <83poj7zika.fsf@gnu.org> References: <78ace0d5-59f1-0d7d-1f0e-b589a947d76c@live.com> 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 1485592703 18178 195.159.176.226 (28 Jan 2017 08:38:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 28 Jan 2017 08:38:23 +0000 (UTC) Cc: 25557-done@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 09:38:18 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 1cXOWU-0003uB-RI for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Jan 2017 09:38:15 +0100 Original-Received: from localhost ([::1]:50464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXOWY-000789-Ny for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Jan 2017 03:38:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXOWL-00076A-Rt for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 03:38:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXOWI-0004sZ-Mn for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 03:38:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50572) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cXOWI-0004sP-Jf for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 03:38:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cXOWI-0004QX-Dd for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2017 03:38:02 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Jan 2017 08:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 25557 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 25557@debbugs.gnu.org, eliz@gnu.org, clement.pitclaudel@live.com Original-Received: via spool by 25557-done@debbugs.gnu.org id=D25557.148559266616990 (code D ref 25557); Sat, 28 Jan 2017 08:38:02 +0000 Original-Received: (at 25557-done) by debbugs.gnu.org; 28 Jan 2017 08:37:46 +0000 Original-Received: from localhost ([127.0.0.1]:48770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXOW2-0004Py-Do for submit@debbugs.gnu.org; Sat, 28 Jan 2017 03:37:46 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXOW0-0004Pl-E7 for 25557-done@debbugs.gnu.org; Sat, 28 Jan 2017 03:37:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXOVs-0004mt-37 for 25557-done@debbugs.gnu.org; Sat, 28 Jan 2017 03:37:39 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXOVs-0004mp-0P; Sat, 28 Jan 2017 03:37:36 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1466 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cXOVq-0000lS-GY; Sat, 28 Jan 2017 03:37:35 -0500 In-reply-to: <78ace0d5-59f1-0d7d-1f0e-b589a947d76c@live.com> (message from =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel on Fri, 27 Jan 2017 17:05:28 -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:128709 Archived-At: > From: Clément Pit--Claudel > Date: Fri, 27 Jan 2017 17:05:28 -0500 > > There seems to be a few issues in the docstring of `format': > > > %g means print a number in exponential notation > > or decimal-point notation, whichever uses fewer characters. > > This seems wrong: > > (format "%g" 3.0) ⇒ "3", but > (format "%f" 3.0) ⇒ "3.000000", and > (format "%e" 3.0) ⇒ "3.000000e+00", so %g is neither %f nor %e. Fixed. > > The # flag means to use an alternate display form [...] > > for %e, %f, and %g, it causes a decimal point to be included even if > > the precision is zero. > > This seems incomplete: > > (format "%#.5g" 3) ⇒ "3.0000", while > (format "%.5g" 3) ⇒ "3", so # doesn't just cause changes when the precision is 0. I don't understand what you are trying to say (nor the significance of the '.' flag in the example). '#' forces %g to leave the trailing zeros after the decimal, so I added that -- is that what you wanted to say? > > For %e, %f, and %g sequences, the number after the "." in the > > precision specifier says how many decimal places to show > > This seems wrong, too: > > (format "%.5g" 3.0) ⇒ "3", not "3.00000" > (format "%.5g" 3.1) ⇒ "3.1", not "3.10000" Fixed. > Similar problems seem to exist in the actual documentation. If you mean the ELisp manual, I fixed that as well. > 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? Anyway, thanks; I'm marking this bug done.