diff options
| author | Paul Eggert | 2018-06-25 12:21:40 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-06-25 12:23:08 -0700 |
| commit | d0e2a341dd9a9a365fd311748df024ecb25b70ec (patch) | |
| tree | aa5b4e9f33777155349c3aacefece4d25199b887 /doc/lispref/strings.texi | |
| parent | 27a21970f6faa9baf42823f731b7842b075e86eb (diff) | |
| download | emacs-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/strings.texi')
| -rw-r--r-- | doc/lispref/strings.texi | 11 |
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 |
| 924 | Replace the specification with the base-eight representation of an | 924 | Replace the specification with the base-eight representation of an |
| 925 | unsigned integer. | 925 | unsigned integer. The object can also be a nonnegative floating-point |
| 926 | number that is formatted as an integer, dropping any fraction, if the | ||
| 927 | integer does not exceed machine limits. | ||
| 926 | 928 | ||
| 927 | @item %d | 929 | @item %d |
| 928 | Replace the specification with the base-ten representation of a signed | 930 | Replace the specification with the base-ten representation of a signed |
| 929 | integer. | 931 | integer. The object can also be a floating-point number that is |
| 932 | formatted 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 |
| 934 | Replace the specification with the base-sixteen representation of an | 937 | Replace the specification with the base-sixteen representation of an |
| 935 | unsigned integer. @samp{%x} uses lower case and @samp{%X} uses upper | 938 | unsigned integer. @samp{%x} uses lower case and @samp{%X} uses upper |
| 936 | case. | 939 | case. The object can also be a nonnegative floating-point number that |
| 940 | is formatted as an integer, dropping any fraction, if the integer does | ||
| 941 | not exceed machine limits. | ||
| 937 | 942 | ||
| 938 | @item %c | 943 | @item %c |
| 939 | Replace the specification with the character which is the value given. | 944 | Replace the specification with the character which is the value given. |