🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #2716

Re: Any ideas on fixed point addition?

#2716
From: Donald Arseneau
Date: Tue, 15 Sep 1992 10:46
25 lines
1219 bytes
In article <1992Sep14.220128.16318@Princeton.EDU>, tvz@zandtwerk.Princeton.EDU () writes...
>Here is a macro for fixed point addition.
> 
>USAGE \FPadd{num1}{num2}\cs
> 
>This sets \cs to num1+num2.


If the somewhat-limited precision of TeX's lengths is enough, how about

\def\FPadd#1#2#3{\FPdim#1\p@ \advance\FPdim#2\p@
  \edef#3{\expandafter\pointless\the\FPdim}}

\newdimen\FPdim

\begingroup 
\catcode`P=12 \catcode`T=12 
\lowercase{
\endgroup\def\pointless #1PT{#1}
}

The final incantation is to get pt with catcode 12 into the syntax 
of \pointless.  \the gives pt with catcode 12.

Donald Arseneau            asnd@reg.triumf.ca
Technical Details
Message-ID: <15SEP199203465090@reg.triumf.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!gumby!destroyer!ubc-cs!unixg.ubc.ca!reg.triumf.ca!asnd
References: <1992Sep14.220128.16318@Princeton.EDU>

Show Full Headers
Complete Article Headers
Newsgroups: comp.text.tex
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!gumby!destroyer!ubc-cs!unixg.ubc.ca!reg.triumf.ca!asnd
From: asnd@reg.triumf.ca (Donald Arseneau)
Subject: Re: Any ideas on fixed point addition?
Message-ID: <15SEP199203465090@reg.triumf.ca>
Summary: Use dimensions 
News-Software: VAX/VMS VNEWS 1.41    
Sender: news@unixg.ubc.ca (Usenet News Maintenance)
Nntp-Posting-Host: reg.triumf.ca
Organization: TRIUMF: Tri-University Meson Facility
References: <1992Sep14.220128.16318@Princeton.EDU>
Date: Tue, 15 Sep 1992 10:46:00 GMT
Lines: 25