ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Taco Hoekwater <taco@elvenkind.com>
Cc: tobias.burnus@physik.fu-berlin.de, ntg-context@ntg.nl
Subject: Re: Calculating in TeX
Date: Thu, 6 Dec 2001 12:27:06 +0100	[thread overview]
Message-ID: <20011206122706.5fbb6f91.taco@elvenkind.com> (raw)
In-Reply-To: <601908040.20011206105015@bigfoot.com>

"Giuseppe Bilotta" <bourbaki@bigfoot.com> 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


  reply	other threads:[~2001-12-06 11:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-05 21:31 Tobias Burnus
2001-12-06  9:50 ` Giuseppe Bilotta
2001-12-06 11:27   ` Taco Hoekwater [this message]
2001-12-06 14:06 e_w_g
     [not found] <Pine.BSF.4.30.0112052223001.3513-100000@chip.physik.fu-ber lin.de>
2001-12-10  8:46 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011206122706.5fbb6f91.taco@elvenkind.com \
    --to=taco@elvenkind.com \
    --cc=ntg-context@ntg.nl \
    --cc=tobias.burnus@physik.fu-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).