From: Jeff Weeks Newsgroups: comp.os.msdos.djgpp Subject: fixed point math: NEED HELP QUICK! Date: 28 Jan 1997 20:12:38 GMT Organization: Internet News Service Lines: 37 Message-ID: <5clmjm$ee3@nr1.toronto.istar.net> NNTP-Posting-Host: news.linkd.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit XPident: Unknown To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi y'all :) I'm having some rather strange problems with fixed point math that I'd like to clear up really quick. I've already taken to much time on this function. Anyway, here's my problem; To my understanding the following are 100% equal: other_stuff = stuff / 256; other_stuff = stuff << 8; assuming that: int stuff = some_fixed_point_number; int other_stuff; HOWEVER, they don't seem to be equal!!! Whenever I use the "<< 8" method to convert a fixed point number into a regular int I always get a seg fault after using the result. If I divide by 256 then it's fine. As you can guess though, I'd rather use the "<< 8" method because it's faster. Why aren't these two methods equal? Why doesn't "<< 8" work! I really need an answer to this one. PS: Please repond to my email address (pweeks AT execulink DOT com) because my ISP has been doing some screwy stuff and sometimes I can't get to this newsgroup. Jeff -------------------------------------------- - Code X Software - Programming to a Higher Power email: mailto:pweeks AT execulink DOT com web: http://www.execulink.com/~pweeks/ --------------------------------------------