Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
ansi-test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ansi-test
ansi-test
Commits
91e61bee
Commit
91e61bee
authored
Nov 21, 2019
by
Daniel Kochmański
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patch-2' into 'master'
Comment FORMAT.F.45 See merge request
!33
parents
034d1add
1a5850ba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
printer/format/format-f.lsp
printer/format/format-f.lsp
+19
-1
No files found.
printer/format/format-f.lsp
View file @
91e61bee
...
...
@@ -535,8 +535,26 @@
collect (list i c f1 s1 s2))
nil)
;;; Rationale for FORMAT.F.45: CLHS 22.3.3.1 states that "d is the number of
;;; digits to print after the decimal point;" AND that the number is printed
;;; "rounded to d fractional digits".
;;;
;;; If we want to print 1.1 in a field of width 0, then we compute D to be W,
;;; minus the number of digits to be printed before the decimal point, minus 1
;;; for the decimal point. So, in this case, D = W - 1 - 1 = 0.
;;;
;;; This means that we must print exactly 0 digits after the decimal point and
;;; that we must round the number to 0 fractional digits. The latter is doable
;;; and we round 1.1 to 1.0, BUT the first contradicts the first paragraph of
;;; 22.3.3.1 which states, "arg is printed as a float". "1." is not a float in
;;; Common Lisp, since it is read as the integer 1 in base 10.
;;;
;;; Therefore, in order to work around this corner case, we explicitly print one
;;; decimal digit so that the resulting number is recognizable as a float. Since
;;; the number was rounded to 0 decimal digits, then this digit is 0. This way,
;;; we get "1." concatenated with "0" that gives us "1.0".
(def-format-test format.f.45
"~2f
" (1.1) "1
.0")
"~2f
~2f" (1.1 1.9) "1.0 2
.0")
(def-format-test format.f.45b
"~3f" (1.1) "1.1")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment