Define three procedures for format ~F

hamay1010 <[email protected]> Sat, 28 Oct 2017 19:14:22 +0900
Newsgroups gmane.lisp.scheme.srfi.srfi-48
Message-ID <CACt-mtNNT8-4o5E=S3=Epcz+ZudhoE6vV=gGFMdiZUdTVxJ8DA@mail.gmail.com>
--94eb2c06c9f0507121055c98ab23
Content-Type: text/plain; charset="UTF-8"
X-SL-Modified: truncated_text

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

I created a pull request as follows.
https://github.com/scheme-requests-for-implementation/srfi-48/pull/3

--94eb2c06c9f0507121055c98ab23
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-SL-Modified: truncated_html

<div dir=3D"ltr"><div>I found that the behavior of format ~F is determined =
by the implementation<br></div><div><div>of &#39;number-&gt;string&#39;.</d=
iv><div><br></div><div>If (number-&gt;string (exact-&gt;inexact 0.0003)) re=
turns &quot;0.0003&quot;,</div><div>(format &quot;~1,2F&quot; 0.0003) retur=
ns &quot;0.00&quot;.</div><div><br></div><div>If (number-&gt;string (exact-=
&gt;inexact 0.0003)) returns &quot;3.0e-4&quot;,</div><div>(format &quot;~1=
,2F&quot; 0.0003) returns &quot;3.00e-4&quot;.</div><div><br></div><div>I t=
hink this behavior should be customizable but it seems difficult.</div><div=
><br></div><div>So, I defined three procedures near the top of code and add=
ed a comment</div><div>that explains them.</div><div><br></div><div>If syst=
em provides a kind of &#39;number-&gt;string&#39; that can select whether</=
div><div>output is fixed-point notation or exponential notation, user can u=
se it</div><div>by overwriting these procedures.</div><div><br></div><div>A=
lso, I refactored some code and confirmed all tests are passed in the</div>=
<div>following environment.</div><div><br></div><div>OS: Windows 8.1 (64bit=
)</div><div>DevTool: MSYS2/MinGW-w64 (64bit) (gcc version 7.1.0 (Rev2, Buil=
t by MSYS2 project))</div><div>Scheme: Gauche v0.9.6_pre4, Sagittarius v0.8=
.4, Racket v6.7</div></div><div><br></div><div><div>I created a pull reques=
t as follows.</div><div><a href=3D"https://github.com/scheme-requests-for-i=
mplementation/srfi-48/pull/3">https://github.com/scheme-requests-for-implem=
entation/srfi-48/pull/3</a></div><div><br></div><div></div></div></div>

--94eb2c06c9f0507121055c98ab23--