home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / text / tex / 15310 < prev    next >
Encoding:
Text File  |  1993-01-22  |  2.1 KB  |  54 lines

  1. Path: sparky!uunet!news.claremont.edu!ucivax!news.service.uci.edu!unogate!mvb.saic.com!info-tex
  2. From: Peter Schmitt <A8131DAL%AWIUNI11.BITNET@SHSU.edu>
  3. Newsgroups: comp.text.tex
  4. Subject: Re: Two questions
  5. Message-ID: <10258259@MVB.SAIC.COM>
  6. Date: Fri, 22 Jan 93 13:14:52 MEZ
  7. Organization: Info-Tex<==>Comp.Text.Tex Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 43
  10.  
  11. On Thu, 21 Jan 93 20:03:58 EST you said:
  12. >
  13. >The second question, that of formatting numbers to insert a comma every
  14. >third place, is somewhat more nuanced, as I knew, and neither of the two
  15. >solutions I received worked right for all numbers.  Since all my numbers
  16. >had fewer than 6 digits, the following seems to work, as far as I have
  17. >tested it.  It is a modification of one of the answers.  One that will
  18. >work in general would take more work.  The problem is to suppress
  19. >leading zeroes at the beginning of a number, while not suppressing them
  20. >beyond that point.
  21. >
  22. >\def\The#1{%
  23. >    \ifnum#1=0 000
  24. >    \else \ifnum#1<10 00\the#1
  25. >          \else \ifnum#1<100 0\the#1
  26. >                \else\the#1
  27. >                \fi
  28. >          \fi
  29. >    \fi}
  30. >\newcount\a \newcount\b
  31. >\def\fnumber#1{\a=#1 \b=\a \ifnum#1<1000 \$#1 \else \$%
  32. >     \divide\a by 1000 \the\a,\multiply\a by 1000 \advance\b by -\a
  33. >\The\b\fi}
  34. >
  35. I was somewhat hasty - it occurred to only after leaving the terminal that I
  36. forgot zeroes for small remainders.
  37. Your addition is, of course, just what is needed.
  38. But may I suggest to replace
  39.    πTheπb just by
  40.    πifnumπb<100 0πifnumπb<10 0πfiπfiπtheπb
  41. it seems to slightly more efficient (you need not check for πb=0
  42. because then πtheπb will produce one 0) and slightly shorter
  43. (I hope I did not introduche a new mistake now!)
  44.  
  45. Peter
  46.  
  47.  
  48. Peter Schmitt                             a8131dal@awiuni11.edvz.univie.ac.at
  49.                                                         schmitt@awirap.bitnet
  50. -----------------------------------------------------------------------------
  51. Institute of Mathematics                                     Strudlhofgasse 4
  52. University of Vienna                                              A-1090 Wien
  53.                                                                       Austria
  54.