From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/6279 Path: main.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: Calculating in TeX Date: Thu, 6 Dec 2001 12:27:06 +0100 Sender: owner-ntg-context@let.uu.nl Message-ID: <20011206122706.5fbb6f91.taco@elvenkind.com> References: <601908040.20011206105015@bigfoot.com> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1035396812 9075 80.91.224.250 (23 Oct 2002 18:13:32 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 18:13:32 +0000 (UTC) Cc: tobias.burnus@physik.fu-berlin.de, ntg-context@ntg.nl Original-To: "Giuseppe Bilotta" In-Reply-To: <601908040.20011206105015@bigfoot.com> Xref: main.gmane.org gmane.comp.tex.context:6279 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:6279 "Giuseppe Bilotta" wrote: > > TB> Now I was thinking where I could do so in TeX. (I think there are > TB> macros in ConTeXt, but I cannot find them.) > > e-TeX has some arithmetic primitives. Don't know if they are > somehow wrapped in ConTeXt, though. It is rather straightforward in normal TeX as well, as long as they are integers. Floats are a bit of a problem. For those, perhaps a texutil plugin would be easier. Then again, that would alway force another run. Assuming integers, try this: \def\mycalc#1#2#3{% \count1=#1 \advance\count1 #2 \advance\count1 #3 \ifnum\count1 > 0 \count3=#1 \count5=#2 \multiply \count5 2 \advance\count3 \count5 \count5=#3 \multiply \count5 3 \advance\count3 \count5 % \multiply\count3 10 \divide \count3 \count1 \expandafter\domycalc\the\count3\relax\quit \else --% \fi } \def\domycalc#1#2\quit{% \if#2\relax .#1% \else #1\domycalc#2\quit% \fi } \mycalc{1}{3}{5} -- groeten, Taco