home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!pmafire!news.dell.com!swrinde!zaphod.mps.ohio-state.edu!rpi!ghost.dsi.unimi.it!insa-lyon.fr!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!fuug!sulo!ttkoiv
- From: ttkoiv@sulo.otol.fi (Timo Koivisto)
- Subject: Re: SANE num2str problem
- Message-ID: <1993Jan25.224039.14109@sulo.otol.fi>
- Organization: Oulu Institute of Technology, Finland
- References: <ksuiter-250193114015@hurston.zoo.duke.edu>
- Date: Mon, 25 Jan 1993 22:40:39 GMT
- Lines: 65
-
- From article <ksuiter-250193114015@hurston.zoo.duke.edu>, by ksuiter@acpub.duke.edu (Karl A. Suiter):
- > Hi,
- >
- > After dutifully searching through my copies of Inside Mac, Spinside Mac,
- > Macintosh Programming Secrets, etc., I have to admit that I am stuck on
- > this one (probably trivial) programming problem. It has to do with using
- > the SANE num2str routine in Think C 5.04. The prototype for num2str is
- > defined as
- >
- > void num2str(decform *, extended, void *);
- >
- > thus, I have the following snippet of code that should (I think) work
- >
- > void convertNum()
- > {
- > decform extStuff;
- > Str255 tempStr;
- > extended theNum;
- >
- > extStuff.style = FIXEDDECIMAL;
- > extStuff.digits = 2;
- > theNum = 1.00;
- > num2str(&extStuff, theNum &tempStr);
- > printf("%s", tempStr);
- > }
-
- I have used something like this in my code:
-
- void convertNum()
- {
- decform extStuff;
- Str255 tempStr;
- extended temp;
- long double theNum;
-
- theNum = 1.00;
- #if __option(native_fp) && !__option(mc68881)
- temp = theNum;
- #else /* here extended type is a struct */
- x96tox80(&theNum,&temp);
- #endif
-
- extStuff.style = FIXEDDECIMAL;
- extStuff.digits = 2;
- num2str(&extStuff,temp,tempStr);
- printf("%s",tempStr);
- }
-
- I hope this helps!
-
- >
- > Karl
- >
- > ---
- >
- > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- > | Karl A. Suiter, Duke University, Zoology Dept., Durham, NC 27706 |
- > |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|
- > | Voice: (919) 684-2251 | INTERNET: ksuiter@acpub.duke.edu |
- > | FAX: (919) 684-6168 | COMPUSERV: 72701,3543@compserv.com |
- > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
- Timo Koivisto
- ttkoiv@mailnet.otol.fi
-
-