Steve_A_Hales@cup.portal.com (02/12/88)
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? Thanks, a whole bunch, in advance..... Steve Hales UUCP: Steve_A_Hales@cup.portal.com
srt@duke.cs.duke.edu (Stephen R. Tate) (02/13/88)
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."