digitalmars.D - How do you write reals or floats? (I have one sol here)
- hellcatv hotmail.com (9/9) Jun 02 2004 I was desparately browsing through the phobos lib... and I haven't found...
- Walter (8/17) Jun 04 2004 This should work:
- hellcatv hotmail.com (12/33) Jun 04 2004 that's nice but snprintf isn't even provided in dmd0.91 (at least it cla...
- Walter (10/21) Jun 04 2004 claims it
I was desparately browsing through the phobos lib... and I haven't found a way to copy a real to a string I tried snprintf but it would often leave garbage in the string (I'm not sure why yet...but it wouldn't work with gdc) so I wrote my own ftoa http://svn.dsource.org/svn/projects/deliria/turing/ also I have the problem that since it's called ftoa import won't bring it in because when I call ftoa() it says "cannot call module" instead of calling the function
Jun 02 2004
This should work: char[100] buffer; snprintf(buffer, buffer.length, "%Lg", r); <hellcatv hotmail.com> wrote in message news:c9llt3$bs3$1 digitaldaemon.com...I was desparately browsing through the phobos lib... and I haven't found awayto copy a real to a string I tried snprintf but it would often leave garbage in the string (I'm notsurewhy yet...but it wouldn't work with gdc) so I wrote my own ftoa http://svn.dsource.org/svn/projects/deliria/turing/ also I have the problem that since it's called ftoa import won't bring itinbecause when I call ftoa() it says "cannot call module" instead of calling the function
Jun 04 2004
that's nice but snprintf isn't even provided in dmd0.91 (at least it claims it doesn't exist) only sprintf and the buffer overrun stuff that it could (and probably will not) cause is just unfriendly. why is there an atof and no ftoa? :-) or at least a std.string function. either is bound to be faster than having snprintf parse a format string then assign to a preallocated array of undetermined length, and return that to the host program which then has to read the whole string, determine the ending length and truncate it at that point for the rest of the D program to use :-) In article <c9p94o$2kb6$1 digitaldaemon.com>, Walter says...This should work: char[100] buffer; snprintf(buffer, buffer.length, "%Lg", r); <hellcatv hotmail.com> wrote in message news:c9llt3$bs3$1 digitaldaemon.com...I was desparately browsing through the phobos lib... and I haven't found awayto copy a real to a string I tried snprintf but it would often leave garbage in the string (I'm notsurewhy yet...but it wouldn't work with gdc) so I wrote my own ftoa http://svn.dsource.org/svn/projects/deliria/turing/ also I have the problem that since it's called ftoa import won't bring itinbecause when I call ftoa() it says "cannot call module" instead of calling the function
Jun 04 2004
<hellcatv hotmail.com> wrote in message news:c9pclq$2pn6$1 digitaldaemon.com...that's nice but snprintf isn't even provided in dmd0.91 (at least itclaims itdoesn't exist) only sprintfThere's std.c.stdio._snprintf().and the buffer overrun stuff that it could (and probably will not) causeis justunfriendly.I know.why is there an atof and no ftoa? :-) or at least a std.string function. either is bound to be faster thanhavingsnprintf parse a format string then assign to a preallocated array of undetermined length, and return that to the host program which then has toreadthe whole string, determine the ending length and truncate it at thatpoint forthe rest of the D program to use :-)You're right. It just hasn't been done yet.
Jun 04 2004