www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Extending std.conv with floating-point wrapper functions

I was looking into the std.conv module the other evening, and I had thought it
had conversion functions for all of the D numerical types, but sadly I
discovered that it only did the whole-number types. So the next evening I looked
around and found std.string.atof() that does only float and double, and
std.math2's "real atof( in char[] )" function, which does a pretty good job with
float, double, and real right out of the box. With a bit of playing around with
std.math2 yet the next evening I managed to make some useful wrapper functions
that worked well with D's remaining floating-point types: ifloat, idouble,
ireal, cfloat, cdouble, and creal. 

I really think it would be great if Walter would add these functions, or
functions like these to the std.conv before D v1.0. It would make std.conv more
complete, and on top of that, it would save a person's time looking all around
for functions to convert number-types that were converted with
std.string.toString() functions back to their original D's numerical value(s).

Anyways here's the code, hopefully someone will find it useful... also I'll add
this code to my web-site in a day or two for downloading.


































































































































































































































* 1.0i;

























) * 1.0i;

























1.0i;


















































s2, iPos1, iPos2 );



















David L.

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