aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
authorPaul Eggert2018-06-25 12:21:40 -0700
committerPaul Eggert2018-06-25 12:23:08 -0700
commitd0e2a341dd9a9a365fd311748df024ecb25b70ec (patch)
treeaa5b4e9f33777155349c3aacefece4d25199b887 /doc/lispref
parent27a21970f6faa9baf42823f731b7842b075e86eb (diff)
downloademacs-d0e2a341dd9a9a365fd311748df024ecb25b70ec.tar.gz
emacs-d0e2a341dd9a9a365fd311748df024ecb25b70ec.zip
(format "%d" F) now truncates floating F
Problem reported by Paul Pogonyshev (Bug#31938). * src/editfns.c: Include math.h, for trunc. (styled_format): For %d, truncate floating-point numbers and convert -0 to 0, going back to how Emacs 26 did things. * doc/lispref/strings.texi (Formatting Strings): Document behavior of %o, %d, %x, %X on floating-point numbers. * src/floatfns.c (trunc) [!HAVE_TRUNC]: Rename from emacs_trunc and make it an extern function, so that editfns.c can use it. All callers changed. * test/src/editfns-tests.el (format-%d-float): New test.
Diffstat (limited to 'doc/lispref')
-rw-r--r--doc/lispref/strings.texi11
1 files changed, 8 insertions, 3 deletions
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 70ba1aa613e..026ba749cbd 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -922,18 +922,23 @@ Functions}). Thus, strings are enclosed in @samp{"} characters, and
922@item %o 922@item %o
923@cindex integer to octal 923@cindex integer to octal
924Replace the specification with the base-eight representation of an 924Replace the specification with the base-eight representation of an
925unsigned integer. 925unsigned integer. The object can also be a nonnegative floating-point
926number that is formatted as an integer, dropping any fraction, if the
927integer does not exceed machine limits.
926 928
927@item %d 929@item %d
928Replace the specification with the base-ten representation of a signed 930Replace the specification with the base-ten representation of a signed
929integer. 931integer. The object can also be a floating-point number that is
932formatted as an integer, dropping any fraction.
930 933
931@item %x 934@item %x
932@itemx %X 935@itemx %X
933@cindex integer to hexadecimal 936@cindex integer to hexadecimal
934Replace the specification with the base-sixteen representation of an 937Replace the specification with the base-sixteen representation of an
935unsigned integer. @samp{%x} uses lower case and @samp{%X} uses upper 938unsigned integer. @samp{%x} uses lower case and @samp{%X} uses upper
936case. 939case. The object can also be a nonnegative floating-point number that
940is formatted as an integer, dropping any fraction, if the integer does
941not exceed machine limits.
937 942
938@item %c 943@item %c
939Replace the specification with the character which is the value given. 944Replace the specification with the character which is the value given.