Article View: comp.text.tex
Article #10647Re: Two questions
From: Peter Schmitt
Date: Fri, 22 Jan 1993 12:14
Date: Fri, 22 Jan 1993 12:14
43 lines
2242 bytes
2242 bytes
On Thu, 21 Jan 93 20:03:58 EST you said:
>
>The second question, that of formatting numbers to insert a comma every
>third place, is somewhat more nuanced, as I knew, and neither of the two
>solutions I received worked right for all numbers. Since all my numbers
>had fewer than 6 digits, the following seems to work, as far as I have
>tested it. It is a modification of one of the answers. One that will
>work in general would take more work. The problem is to suppress
>leading zeroes at the beginning of a number, while not suppressing them
>beyond that point.
>
>\def\The#1{%
> \ifnum#1=0 000
> \else \ifnum#1<10 00\the#1
> \else \ifnum#1<100 0\the#1
> \else\the#1
> \fi
> \fi
> \fi}
>\newcount\a \newcount\b
>\def\fnumber#1{\a=#1 \b=\a \ifnum#1<1000 \$#1 \else \$%
> \divide\a by 1000 \the\a,\multiply\a by 1000 \advance\b by -\a
>\The\b\fi}
>
I was somewhat hasty - it occurred to only after leaving the terminal that I
forgot zeroes for small remainders.
Your addition is, of course, just what is needed.
But may I suggest to replace
ãTheãb just by
ãifnumãb<100 0ãifnumãb<10 0ãfiãfiãtheãb
it seems to slightly more efficient (you need not check for ãb=0
because then ãtheãb will produce one 0) and slightly shorter
(I hope I did not introduche a new mistake now!)
Peter
Peter Schmitt a8131dal@awiuni11.edvz.univie.ac.at
schmitt@awirap.bitnet
-----------------------------------------------------------------------------
Institute of Mathematics Strudlhofgasse 4
University of Vienna A-1090 Wien
Austria
Technical Details
Message-ID:
<10258259@MVB.SAIC.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!news.claremont.edu!ucivax!news.service.uci.edu!unogate!mvb.saic.com!info-texShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!news.claremont.edu!ucivax!news.service.uci.edu!unogate!mvb.saic.com!info-tex From: Peter Schmitt <A8131DAL%AWIUNI11.BITNET@SHSU.edu> Newsgroups: comp.text.tex Subject: Re: Two questions Message-ID: <10258259@MVB.SAIC.COM> Date: Fri, 22 Jan 93 13:14:52 MEZ Organization: Info-Tex<==>Comp.Text.Tex Gateway X-Gateway-Source-Info: Mailing List Lines: 43