🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: sci.crypt
Article #3988

Re: Fixed Point Math?

#3988
From: Stephen R. Tate
Date: Fri, 12 Feb 1988 22:59
33 lines
1958 bytes
In article <3140@cup.portal.com> Steve_A_Hales@cup.portal.com writes:
>Aloha!
>  Where can I find some information on how to create a fixed point math
>package.  I need to add, subtract, multply, and divide.  I need 16 bits
>of precision on each side of the decimal point.
>
>Can anyone point me to a place where I might find out how to do this?
>

A "package"?  If all you need is add, subtract, multiply, and divide,
then it's incredibly easy.  Add and subtract are just integer operations
on 32 bits, multiply is easy enough by splitting into 16 bit chunks
and doing fractions and decimal parts seperately.  The only possible
problem is division, which isn't really a problem -- the same sort
of splitting can be done for one term, and you can just assume the
decimal place is moved in the other (and "assume" it is moved back
when you are done -- actually no shifting of the number is necessary).
Anyway, if you sit down and think about it that might be more clear
than I just made it.

Also a suggestion:  use C++.  You can define a new type for fixed
point numbers, and define addition, subtraction, etc. on them as
the regular operators, then you can write regular equations (e.g.,
"a=b+c*d") to manipulate the values.  That's a lot better than
trying to call subroutines for every operation.

Hope that helps.

-- 
Steve Tate			UUCP: ..!{ihnp4,decvax}!duke!srt
				CSNET: srt@duke
				ARPA:  srt@cs.duke.edu
"There ain't nothin' in the world that a T-Bone Shuffle won't cure."
Technical Details
Message-ID: <11104@duke.cs.duke.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!decvax!ucbvax!agate!ig!uwmcsd1!bbn!gatech!mcnc!duke!srt
References: <3140@cup.portal.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!decvax!ucbvax!agate!ig!uwmcsd1!bbn!gatech!mcnc!duke!srt
From: srt@duke.cs.duke.edu (Stephen R. Tate)
Newsgroups: sci.crypt
Subject: Re: Fixed Point Math?
Message-ID: <11104@duke.cs.duke.edu>
Date: 12 Feb 88 22:59:59 GMT
References: <3140@cup.portal.com>
Reply-To: srt@duke.UUCP (Stephen R. Tate)
Organization: Duke University, Durham NC
Lines: 33
Posted: Fri Feb 12 17:59:59 1988