[Issue 3248] lossless floating point formatting

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 12 18:21:22 PDT 2009


Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
                 CC|                            |smjg at iname.com

--- Comment #3 from Stewart Gordon <smjg at iname.com>  2009-08-12 18:21:21 PDT ---
I can see a few possible approaches to lossless floating point formatting:

(a) decimal with infinite precision, minus trailing zeros
(b) minimum number of significant figures guaranteed to be unique, minus
trailing zeros
(c) the shortest possible string that, when parsed as a floating point, is
exactly this number

(a) clearly isn't what the reporter is asking for.

(b) seems straightforward.  (Is the number of s.f. in question just the .dig

(c) is optimal, and could probably be implemented quite simply (not sure
whether it would be most efficient though) with the aid of the nextUp and
nextDown functions.  This would also address the question in comment 1, though
I'm not sure how easy it would be to implement this efficiently.

But (b) and (c) are ambiguous: do we go by uniqueness/exactitude in the real
type or in the actual floating point type being used?  I can see that sometimes
the app'll know what type it will later be read into, and sometimes it won't.

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

More information about the Digitalmars-d-bugs mailing list