Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: Nagesh_Pabbisetty.Henr801C@xerox.COM Newsgroups: comp.windows.x Subject: Re: right shifting negative numbers considered harmful Message-ID: <"24-Jan-91..9:49:57.EST".*.Nagesh_Pabbisetty.Henr801C@Xerox.com> Date: 24 Jan 91 14:49:57 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 45 Dear X server hackers, My copy of the ANSI C spec says that when right shifting E1 >> E2, "If E1 has a signed type, whether the right shift is logical (fill with zeros) or arithmetic (fill with a copy of the sign bit) is implementation-defined." (section 3.3.7) Consider the following fragment of code from the MIARCOCTANTSHIFT macro in mizerarc.h ... d = b - (a >> 1) - d + (k3 >> 3); \ ... this is called out from the cfb arc drawing routines. Note that variable a can be negative. I have the misfortune to be running on an architecture without an arithmetic right shift instruction, and so my compiler has exercised it's "implementation-defined" option. In the interests of portability, can someone arrange to fix this apparent ANSI non-compliance in the standard distribution? I'm using R4. Perhaps it is already fixed in R5. Does anybody know? many thanks. Andy Lowe andy@nth.com I am glad(;-) to see that I am not the only one who feels that way. I got bitten by this in the arc drawing code. It took us quite a while to locate and change right shifts to divides (:-( - nagesh (pabbiset@arisia.xerox.com) ------------------------------------------------------------------------------- Intelnet: 8*227-5458 MaBell: (716)427-5458 XNS : pabbisetty:henr801c:xerox Snail Mail: Arpa : pabbiset@arisia.xerox.com 1350 Jefferson Road, 801-27C, Rochester, NY 14623. -------------------------------------------------------------------------------