ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Calculating in TeX
@ 2001-12-05 21:31 Tobias Burnus
  2001-12-06  9:50 ` Giuseppe Bilotta
  0 siblings, 1 reply; 5+ messages in thread
From: Tobias Burnus @ 2001-12-05 21:31 UTC (permalink / raw)


Hi,

I have a nice document where I need to perform small calculation (actually
only calculating the average value):
 if((#1+#2+#3) != 0)
   (#1*1 + #2*2 + #3*3)/(#1+#2+#3)
 else
   "--"

Now I was thinking where I could do so in TeX. (I think there are some
macros in ConTeXt, but I cannot find them.)

The output should be of the form "1{,}4" (i.e. separator is a {,} and I
get one figure after the separator).

If there is no good solution I will write a script which calculates this
values and does a inline replacement of the data. -- This is not that
error save since one needs to make sure that this script is run before
texexec...

Tobias


^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: Calculating in TeX
@ 2001-12-06 14:06 e_w_g
  0 siblings, 0 replies; 5+ messages in thread
From: e_w_g @ 2001-12-06 14:06 UTC (permalink / raw)


Tobias Burnus schrieb:
> 
> I have a nice document where I need to perform small 
> calculation (actually 
> only calculating the average value):
>  if((#1+#2+#3) != 0)
>    (#1*1 + #2*2 + #3*3)/(#1+#2+#3)
>  else
>    "--"
> 
> Now I was thinking where I could do so in TeX. (I think 
> there are some 
> macros in ConTeXt, but I cannot find them.)
> 

There is the fp package for latex. It provides rather complete 
fixed-point arithmetic. I have never used it, but probably it is 
generic enough to work with context. If not, there is the fltpoint 
package which will definitely work, but it is limited to addition, 
subtraction, multiplication and division (if-then-else could be done 
too). 

Eckhart


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <Pine.BSF.4.30.0112052223001.3513-100000@chip.physik.fu-ber lin.de>]

end of thread, other threads:[~2001-12-10  8:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-05 21:31 Calculating in TeX Tobias Burnus
2001-12-06  9:50 ` Giuseppe Bilotta
2001-12-06 11:27   ` Taco Hoekwater
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

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).