www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Requesting a final review: on the floating-point funcs for conv.d

Well, first off I'd like to give many thanks to Ben Hinkle for his reviews! I
believe, I've improved this code to a point that I feel some pride in having
spend so much time in writing it. (Now, I just hope Walter won't wait six months
to put it in, tho I know he's busy man.)

Changes done since last review:
-------------------------------
* deleted the getFloatStrings() function which did double-checks on strings
before they were sended into the std.math2.atof() function, mainly because it
would return zeros even when the string should've been a error. Plus I decided
that since Walter was spenting some of his time improving the std.string.atof()
function that maybe I should switch to it. But I didn't discovered until this
weekend that the std.string.atof() was able to catch unwanted string instead of
return zeros. So, all good! :)

* added back in a modified version of the getComplexStrings() function, which is
only called for cfloat, cdouble, and creal datatypes. With the sole purpose of
just spliting up the orginal string into two real string values for processing
thru the strtold() function.

* now instead of calling std.string.atof(), the code is setup to call the
strtold() function which atof() would've called. Also I'm passing a pointer into
the strtold() function pointing to the string's the last character, thus saving
any string duping that would've been going on in toStringz() function if atof()
had been used.

* now instead using down-casting a float / double and comparing against the real
result within the feq() function to catch overflows. I've changed to using a
more logic approach of "if (f > float.max) goto Loverflow;"...which works much
better. Currently complex floats (cfloat, cdouble, and creal) have a bug when
comparing against their .max value...inwhich I did report this problem on the
D.Bugs forum.

* trim out the bit deep-equate compares (i.e. if (b == 0) goto Loverflow;) and
changed them all to negative-state compares (i.e. if (!b) goto Loverflow;).

* fine tuned the unittest a little bit more.

* removed a few unnecessary cast() here and there.

* also, I'm now only importing std.math fabs() and isnan() functions, as well
as, only using the std.string.toString() functions in unittests. And the private
feq() functions are now only used in unittest, and wrapped with a "debug(conv) {
}" statement. There's much less overhead this way. :)
----------------------------------------------------








































































































































































































































































































































































































































































































































































































































strings.















































~ " s2=\"" ~ s2 ~ "\"");
























































































Again many, many thanks to Ben for spenting some time reviewing this code
multiple times.

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------

MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Apr 23 2005