>>>> "Raymond" == Raymond Toy
<raymond.toy(a)ericsson.com> writes:
Raymond> If you don't get 1.0, you have a badly broken system, if
Raymond> you are using IEEE 754. 0.125 and 0.875 can be
Raymond> represented exactly, and so can their sum. If you don't
Raymond> get 1.0, then your reader is broken or your printer. Or,
Raymond> perhaps, + is broken. :-)
But what if I get 1.000? Where is something broken? My point is that
a conscientious human presented with the problem
0.125 0.125 0.125 0.125
0.875 0.875 0.875 0.875
----- ----- ----- -----
will almost certainly complete it with
0.125 0.125 0.125 0.125
0.875 0.875 0.875 0.875
----- ----- ----- -----
1.000 1.000 1.000 1.000
not
0.125 0.125 0.125 0.125
0.875 0.875 0.875 0.875
----- ----- ----- -----
1.0 1.0 1.0 1.0
And surely that's what Rodney wants, too! No?
sjt> Yup. `string-to-int' is an alias for `string-to-number',
sjt> which is (ultimately) just a wrapper around the platform's
sjt> printf implementation.
sjt> What you get is what you get.
Raymond> But it is possible to do a better job.
Raymond> CMUCL prints "8.18e-1" exactly like that.
Which is *arguably wrong* because you've lost a digit of precision. I
really don't think *Rodney* can win this way. Yes, *we* could get
prettier output for the occasional number, but he's working with
tables.
Raymond> Perhaps printf/scanf doesn't use those algorithms.
Microsoft's apparent do, Unices don't. Not worth our effort to
replace them, I suggest, unless somebody != me :-) wants to look up
the various algorithms *and* present the rationales, *and* document
the algorithms so people know what to expect, *as well as* update our
test suite. Without that, we're really no better off than we are at
present, are we? People are still going to be surprised by the output
they get (although in most cases pleasantly so :-).
What is it that makes avoiding `format' worth all that?
(That's an honest question, not a put-down.)
--
School of Systems and Information Engineering
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.