groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Integer arithmetic


From: Tadziu Hoffmann
Subject: Re: [Groff] Integer arithmetic
Date: Thu, 15 Oct 2009 11:18:13 +0200
User-agent: Mutt/1.5.17 (2007-11-01)

> Hello, in real world this is sooo easy:
>
> h = 105,5 mm
> w = h *0.36
>
> In groff world 105.5 and 0.36 needs to come in centimeters,
> then some correction needs to be applied.

Well, in the simple case above, 0.36 does *not* need to come in
centimeters.  It is a simple numerical factor.  The "h" already
contains the centimeters.  So the solution would be

  .nr h 10.55c
  .nr w \nh*36/100
  .\" .tm \nh \nw

In general: multiply first, then divide. If you get an overflow,
multiply in smaller pieces and add the results (0.36 = 3/10 +
6/100). For example:

  .nr w (\nh*3/10)+(\nh*6/100)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]