Define three procedures for format ~F #3
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found that the behavior of format ~F is determined by the implementation
of 'number->string'.
If (number->string (exact->inexact 0.0003)) returns "0.0003",
(format "~1,2F" 0.0003) returns "0.00".
If (number->string (exact->inexact 0.0003)) returns "3.0e-4",
(format "~1,2F" 0.0003) returns "3.00e-4".
I think this behavior should be customizable but it seems difficult.
So, I defined three procedures near the top of code and added a comment
that explains them.
If system provides a kind of 'number->string' that can select whether
output is fixed-point notation or exponential notation, user can use it
by overwriting these procedures.
Also, I refactored some code and confirmed all tests are passed in the
following environment.
OS: Windows 8.1 (64bit)
DevTool: MSYS2/MinGW-w64 (64bit) (gcc version 7.1.0 (Rev2, Built by MSYS2 project))
Scheme: Gauche v0.9.6_pre4, Sagittarius v0.8.4, Racket v6.7