Skip to content
Snippets Groups Projects
Commit a660c8de authored by rtoy's avatar rtoy
Browse files

(format nil "~5f" 1d-10) was printing out way too many zeroes,

exceeding the specified width.  I think the correct answer is
".0000".

So, add a parameter, allow-overflow-p, to FLONUM-TO-STRING to allow
the width constraint to be exceeded.  This defaults to T.
FLONUM-TO-STRING looks at this and decides whether or not to print out
all the leading zeroes or not.  In FIXED-FORMAT-AUX, set
allow-overflow-p to NIL so we don't exceed the width.

I wish there were another way to do this, but I can't think of one
right now.

All print tests pass, and add the following test:

(format nil "~5F" 1d-10) -> ".0000"

print.lisp:
o Change FLONUM-TO-STRING to use keyword parameters instead of
  optional parameters.
o Add :ALLOW-OVERFLOW-P, defaulting to T.
o Use :ALLOW-OVERFLOW-P to determine if all the leading zeroes should
  be printed or not.

format.lisp:
o Update calls to FLONUM-TO-STRING to use keywords parameters.
o In FIXED-FORMAT-AUX, set :ALLOW-OVERFLOW-P to NIL
parent 6e51dd5c
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment