Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Format function's F directive's k parameter fails when preceded by a tilde and 2 commas #51

Closed
ninejaguar opened this issue Jun 17, 2017 · 3 comments

Comments

@ninejaguar
Copy link

Copied from Trac Issue#1416 per request from rme. In addition, see earlier Trac Issue#1297. Links are at the bottom of this Issue.

Environment:
CCL version 1.11-r16635 64bit under Windows 10 64bit

Possible issue:
The Format function's F directive's k parameter fails to move the decimal point of the floating point argument to the right when preceded by a tilde and 2 consecutive commas. This fails in Clozure, but works in SBCL v1.3.15 64bit and in Clisp 2.49 when tested.

Example1: The Clozure prompt is "?". Note the issue is that 0.1 is returned rather than 10.0

? (format t "10 Percent ~,,2f ~%" .10)
10 Percent 0.1
NIL

Example2: The SBCL prompt is an asterisk "*". Clisp produces the same result.

* (format t "10 Percent ~,,2f ~%" .10)
10 Percent 10.0
NIL

Other scenarios seem to work fine...


Example3: Clozure produces the same result as SBCL Example4 if a 1 is entered for the d parameter (decimal digits) between the two commas.

? (format t "10 Percent ~,1,2f ~%" .10)
10 Percent 10.0
NIL

Example4: SBCL produces the same result as Clozure Example3 when entering a 1 between the two commas.

* (format t "10 Percent ~,1,2f ~%" .10)
10 Percent 10.0
NIL

Example5: Clozure "?" & SBCL "*" produce the same results when entering a 0 between the two commas.

? (format t "10 Percent ~,0,2f ~%" .10)
10 Percent 10.
NIL

* (format t "10 Percent ~,0,2f ~%" .10)
10 Percent 10.
NIL

Reference:

CLHS: 22.3.3.1 Tilde F: Fixed-Format Floating-Point.

"The full form is ~w,d,k,overflowchar,padcharF. The parameter w is the width of the field to be printed; d is the number of digits to print after the decimal point; k is a scale factor that defaults to zero."

http://www.lispworks.com/documentation/HyperSpec/Body/22_cca.htm

Original Trac Issue Tickets:
https://trac.clozure.com/ccl/ticket/1297
https://trac.clozure.com/ccl/ticket/1416

xrme added a commit that referenced this issue Mar 28, 2018
Although the spec says "If both w and d are omitted, then the effect
is to print the value using ordinary free-format output", this
surely cannot mean that k (the scale factor) would be ignored in
that case.

See #51 and #72
xrme added a commit that referenced this issue Mar 28, 2018
Although the spec says "If both w and d are omitted, then the effect
is to print the value using ordinary free-format output", this
surely cannot mean that k (the scale factor) would be ignored in
that case.

See #51 and #72
@xrme
Copy link
Member

xrme commented Mar 28, 2018

fixed in c80d02b and cherry-picked to 1.11 in 1de27e0

@xrme xrme closed this as completed Mar 28, 2018
@ninejaguar
Copy link
Author

ninejaguar commented Mar 29, 2018 via email

@ninejaguar
Copy link
Author

ninejaguar commented Mar 29, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants