digitalmars.D - Requesting a 2nd review: on the floating-point funcs for conv.d
- David L. Davis (789/789) Apr 16 2005 Well, I've been pretty busy this past week reworking all of these "from ...
- TechnoZeus (3/792) Apr 21 2005 Got a link to a listing without the "#" character at the start of each l...
- pragma (11/12) Apr 21 2005 No need, just use the following util to process the file.
- TechnoZeus (3/17) Apr 21 2005 Thanks. :)
- Ben Hinkle (24/819) Apr 22 2005 It's looking better and better. I hope Walter eventually takes it. My
- Ben Hinkle (9/115) Apr 22 2005 Some comments about getFloatStrings. I also looked at the definition of ...
- David L. Davis (13/18) Apr 23 2005 Ben many thanks for all your advise! I've made the changes in your sugge...
Well, I've been pretty busy this past week reworking all of these "from char[]to floating-point" functions (based on advise gotten from Ben Hinkle) that I'd like Walter to include into std.conv. With the sol purpose of filling in the gap of the missing conversion functions for the following datatypes: float, double, real, ifloat, idouble, ireal, cfloat, cdouble, and creal. If anyone has any interest at all, please at least use an eye-ball or two to look over the code, and better yet, if you have the time, copy and paste this code into dmd v0.121's version of conv.d to test it a bit. Thanks in advance, 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 16 2005
TZ "David L. Davis" <SpottedTiger yahoo.com> wrote in message news:d3s8pt$j68$1 digitaldaemon.com...Well, I've been pretty busy this past week reworking all of these "from char[]to floating-point" functions (based on advise gotten from Ben Hinkle) that I'd like Walter to include into std.conv. With the sol purpose of filling in the gap of the missing conversion functions for the following datatypes: float, double, real, ifloat, idouble, ireal, cfloat, cdouble, and creal. If anyone has any interest at all, please at least use an eye-ball or two to look over the code, and better yet, if you have the time, copy and paste this code into dmd v0.121's version of conv.d to test it a bit. Thanks in advance, 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 21 2005
In article <d48dvl$5l9$1 digitaldaemon.com>, TechnoZeus says...No need, just use the following util to process the file. // strip.d // useage: strip.exe <infile> <outfile> import std.file; import std.regexp; void main(char[][] args){ if(args.length != 3) return; } - EricAnderton at yahoo
Apr 21 2005
Thanks. :) TZ "pragma" <pragma_member pathlink.com> wrote in message news:d48gbv$7r4$1 digitaldaemon.com...In article <d48dvl$5l9$1 digitaldaemon.com>, TechnoZeus says...No need, just use the following util to process the file. // strip.d // useage: strip.exe <infile> <outfile> import std.file; import std.regexp; void main(char[][] args){ if(args.length != 3) return; } - EricAnderton at yahoo
Apr 21 2005
It's looking better and better. I hope Walter eventually takes it. My comments from going over it with a fine-tooth comb: 1) when returning or testing bit values use true/false instead of 0/1 (or just test the value without having ==true at all). 2) in getFloatStrings if a copy of the strings is really needed try to use a buffer on the stack instead of always dup'ing. Converting a string to a numeric value shouldn't generate garbage unless really needed. For example the calling functions can have a buffer it passes to getFloatString and if it isn't long enough getFloatStrings can reallocate. Also I wouldn't dup the return strings - just let them live as slices if at all possible. 3) in the overflow checking can things like if (!feq(cast(real)f,r)) ... overflow... be replaced with if (r > float.max) ... overflow ... I'm not exactly sure what the original test is catching as overflow - can you explain it in words? 4) can the code cast(ireal)r*1.0i) be replaced with cast(ireal)r or maybe cast(ireal)cast(real)r if that doesn't work? 5) in a few of the toCDouble and friends there are two cast(creal) in a row. Are they needed? thanks for taking a crack at this! -Ben "David L. Davis" <SpottedTiger yahoo.com> wrote in message news:d3s8pt$j68$1 digitaldaemon.com...Well, I've been pretty busy this past week reworking all of these "from char[]to floating-point" functions (based on advise gotten from Ben Hinkle) that I'd like Walter to include into std.conv. With the sol purpose of filling in the gap of the missing conversion functions for the following datatypes: float, double, real, ifloat, idouble, ireal, cfloat, cdouble, and creal. If anyone has any interest at all, please at least use an eye-ball or two to look over the code, and better yet, if you have the time, copy and paste this code into dmd v0.121's version of conv.d to test it a bit. Thanks in advance, 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 22 2005
Some comments about getFloatStrings. I also looked at the definition of atof in std.string. It calls strtold and throws away the end ptr. You might want to directly call strtold and use the end ptr instead of calling atof. Or, since atof calls toStringz, you might want to manage that better, too, since toStringz can (and probably will) dup strings.Why look for f and L?Why change to lower case? If atof needs lower case then I'd say only accept lower case strings.Why use split here? Don't you know exactly where split will actually split?
Apr 22 2005
In article <d4b13j$2iaj$1 digitaldaemon.com>, Ben Hinkle says...Some comments about getFloatStrings. I also looked at the definition of atof in std.string. It calls strtold and throws away the end ptr. You might want to directly call strtold and use the end ptr instead of calling atof. Or, since atof calls toStringz, you might want to manage that better, too, since toStringz can (and probably will) dup strings.Ben many thanks for all your advise! I've made the changes in your suggestions, and have hopefully answered all your questions in my newest post for a final review. Post can be found here: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/22358 I hope you'll look over the newest version, and make a few comments. Thanks again for you help, 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