home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!mcsun!inesc.inesc.pt!mujave!mms
- From: mms@mujave.inesc.pt (Miguel Mira da Silva)
- Subject: econvert(), fconvert()
- Message-ID: <1992Nov12.110609.2229@inesc.pt>
- Sender: mms@mujave (Miguel Mira da Silva)
- Nntp-Posting-Host: mujave.inesc.pt
- Organization: INESC - Inst. Eng. Sistemas e Computadores, LISBOA. PORTUGAL.
- Date: Thu, 12 Nov 1992 11:06:09 GMT
- Lines: 53
-
- I am trying to port some UNIX software to the MAC under Think C 4.0, but there are
- two functions I could not find in any library that comes with Think C. They are:
-
- char *econvert(value, ndigit, decpt, sign, buf)
- double value;
- int ndigit, *decpt, *sign;
- char *buf;
-
- char *fconvert(value, ndigit, decpt, sign, buf)
- double value;
- int ndigit, *decpt, *sign;
- char *buf;
-
- The description on my SUN is:
-
- econvert() converts the value to a null-terminated string of
- ndigit ASCII digits in buf and returns a pointer to buf.
- buf should contain at least ndigit+1 characters. The posi-
- tion of the radix character relative to the beginning of the
- string is stored indirectly through decpt. Thus buf ==
- "314" and *decpt == 1 corresponds to the numerical value
- 3.14, while buf == "314" and *decpt == -1 corresponds to the
- numerical value .0314. If the sign of the result is nega-
- tive, the word pointed to by sign is nonzero; otherwise it
- is zero. The least significant digit is rounded.
-
- fconvert works much like econvert, except that the correct
- digit has been rounded as if for sprintf(%w.nf) output with
- n=ndigit digits to the right of the radix character. ndigit
- can be negative to indicate rounding to the left of the
- radix character. The return value is a pointer to buf. buf
- should contain at least 310+max(0,ndigit) characters to
- accomodate any double-precision value.
-
- Also,
-
- ecvt() and fcvt() are obsolete versions of econvert() and
- fconvert() that create a string in a static data area,
- overwritten by each call, and return values that point to
- that static data. These functions are therefore not reen-
- trant.
-
- I tried already to implement them for myself, but it is not quite obvious.
- I was wondering if anybody has had the same problem, or if the solution
- comes on any book of "C utilities". Any help is appreciated.
-
- Thanks in advance,
-
- Miguel.
-
- ---
- Miguel Mira da Silva
- mms@mujave.inesc.pt
-