delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/30/13:56:48

From: ksinner AT solaria DOT sol DOT net (Kenton E. Sinner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Double to string anybody?
Date: 30 Oct 1996 00:43:36 GMT
Organization: Solaria Public Access UNIX - Milwaukee, WI
Lines: 29
Distribution: world
Message-ID: <5568bo$kdl@hummin.sol.net>
References: <55142b$su AT news DOT sdsmt DOT edu>
NNTP-Posting-Host: hummin.sol.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Olav Kindt (oak9755 AT silver DOT sdsmt DOT edu) wrote:
: Hi there,

: I was wondering if djgpp had the equivalent of the gcvt() function from
: BCC (Yeah i know..). Has anybody implemented these, or do I have to do it
: myself. :-).

: Any pointers to libs containg this one is appreciated.

: PS. For those who doesn't know what i'm talking about: the gcvt function
: converts a floating point number into a string (like itoa does for ints)
: It is not standard ANSI C, so I don't think it is in the DJGPP package. At
: least I couldn't find it.

I had to write my own function for just this purpose.  But it's not hard.
You just take the number modulo 10, which extracts the least significat
digit, convert to the appropriate ascii character, divide by 10, and
repeat the process until the division by 10 yields a zero residue.
(I might not have remembered this correctly, as I don't have immediate
access the the source I wrote, but you can get the gist of it.)

Happy hacking!

--
Ken Sinner                       |  Want to run your OWN life for a change?
ksinner AT solaria DOT sol DOT net          |         Harry Browne for President
                                 |        http://www.HarryBrowne96.org
"It ain't what we don't know that gets us into trouble, as much as what we
do know that ain't so." -- Will Rogers (I think)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019