home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22166 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.3 KB  |  76 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. 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
  3. From: ttkoiv@sulo.otol.fi (Timo Koivisto)
  4. Subject: Re: SANE num2str problem
  5. Message-ID: <1993Jan25.224039.14109@sulo.otol.fi>
  6. Organization: Oulu Institute of Technology, Finland
  7. References: <ksuiter-250193114015@hurston.zoo.duke.edu>
  8. Date: Mon, 25 Jan 1993 22:40:39 GMT
  9. Lines: 65
  10.  
  11. From article <ksuiter-250193114015@hurston.zoo.duke.edu>, by ksuiter@acpub.duke.edu (Karl A. Suiter):
  12. > Hi,
  13. >   After dutifully searching through my copies of Inside Mac, Spinside Mac,
  14. > Macintosh Programming Secrets, etc., I have to admit that I am stuck on
  15. > this one (probably trivial) programming problem.  It has to do with using
  16. > the SANE num2str routine in Think C 5.04.  The prototype for num2str is
  17. > defined as 
  18. >       void num2str(decform *, extended, void *);
  19. > thus, I have the following snippet of code that should (I think) work
  20. > void convertNum()
  21. >  {
  22. >   decform  extStuff;
  23. >   Str255   tempStr;
  24. >   extended theNum;
  25. >   
  26. >   extStuff.style = FIXEDDECIMAL;
  27. >   extStuff.digits = 2;
  28. >   theNum = 1.00;
  29. >   num2str(&extStuff, theNum &tempStr);
  30. >   printf("%s", tempStr);
  31. >  }
  32.  
  33. I have used something like this in my code:
  34.  
  35. void convertNum()
  36.  {
  37.   decform  extStuff;
  38.   Str255   tempStr;
  39.   extended temp;
  40.   long double theNum;
  41.  
  42.   theNum = 1.00;
  43. #if __option(native_fp) && !__option(mc68881)
  44.   temp = theNum;
  45. #else         /* here extended type is a struct */
  46.   x96tox80(&theNum,&temp);
  47. #endif
  48.  
  49.   extStuff.style = FIXEDDECIMAL;
  50.   extStuff.digits = 2;
  51.   num2str(&extStuff,temp,tempStr);
  52.   printf("%s",tempStr);
  53.  } 
  54.  
  55. I hope this helps!
  56.  
  57. >                                                                  Karl
  58. > ---
  59. > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60. > | Karl A. Suiter, Duke University, Zoology Dept., Durham, NC   27706    |
  61. > |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|
  62. > | Voice: (919) 684-2251      |   INTERNET:  ksuiter@acpub.duke.edu      |
  63. > | FAX:   (919) 684-6168      |   COMPUSERV: 72701,3543@compserv.com     |
  64. > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  65.  
  66. Timo Koivisto
  67. ttkoiv@mailnet.otol.fi
  68.  
  69.