home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!reed!bowman
- From: bowman@reed.edu (BoBoRamDos)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Floating Point to String Conversion
- Keywords: International, Worldwide
- Message-ID: <1992Nov21.001658.22424@reed.edu>
- Date: 21 Nov 92 00:16:58 GMT
- Article-I.D.: reed.1992Nov21.001658.22424
- References: <357@snll-arpagw.llnl.gov>
- Organization: Reed College, Portland, OR
- Lines: 36
-
- In article <357@snll-arpagw.llnl.gov> ejfried@snll-arpagw.llnl.gov (friedman_hil
- l ernest j) writes:
- >Question: It seems like it is now possible to do floating point number ->
- >text string conversion using system software instead of sprintf.
-
- Here's what I use:
-
- void ExtendToText(Str255 *outch,extended realNumber)
- {
- short index=0;
- decform theForm;
- decimal theDecimal;
-
- theForm.digits = fFieldLength;
-
- switch (fOutputType) {
- case fixed:
- theForm.style = FIXEDDECIMAL;
- break;
- case scientific:
- theForm.style = FLOATDECIMAL;
- theForm.digits++;
- // FLOATDECIMAL sucks 1 digit to the left of the dec point
- break;
- }
-
-
- num2dec(theForm,realNumber,theDecimal);
- dec2str(theForm,theDecimal,(char *) outch);
- c2pstr((char *) outch);
- }
-
- cheers,
- bobo In seeking the unattainable,
- bowman@reed.edu simplicity only gets in the way.
- A geek, by any other name...
-