From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,582dff0b3f065a52 X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,582dff0b3f065a52 X-Google-Attributes: gid109fba,public X-Google-ArrivalTime: 2001-08-22 18:55:34 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!tor-nx1.netcom.ca!tor-nn1.netcom.ca.POSTED!not-for-mail Message-ID: <3B8462C8.5596C089@yahoo.com> From: Joe Maun Organization: H X-Mailer: Mozilla 4.77 [en] (Win95; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Subject: Re: Subtle Bugs, kudos Ada (was How Ada ...Red Code ...) References: <3B6555ED.9B0B0420@sneakemail.com> <87n15lxzzv.fsf@deneb.enyo.de> <3B672322.B5EA1B66@home.com> <4a885870.0108112341.7ce02ac0@posting.google.com> <3B834E5D.B0D26AB1@adaworks.com> <9lvsic$bet9s$1@ID-9852.news.dfncis.de> <9m0193$grs$1@bird.wu-wien.ac.at> <3B83F042.4CFB073D@home.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 22 Aug 2001 21:56:24 -0400 NNTP-Posting-Host: 216.123.141.23 X-Complaints-To: abuse@attcanada.ca X-Trace: tor-nn1.netcom.ca 998531723 216.123.141.23 (Wed, 22 Aug 2001 21:55:23 EDT) NNTP-Posting-Date: Wed, 22 Aug 2001 21:55:23 EDT Xref: archiver1.google.com comp.lang.ada:12302 comp.lang.c:76298 comp.lang.c++:85018 Date: 2001-08-22T21:56:24-04:00 List-Id: Kaz Kylheku wrote: > > In article <3B83F042.4CFB073D@home.com>, Warren W. Gay VE3WWG wrote: > >#define ACLIP 31744 > >... > >unsigned char > >st_linear_to_Alaw( sample ) > >short sample; > > { > > static const unsigned char exp_lut[128] = { ...snip... }; > > int sign, exponent, mantissa; > > unsigned char Alawbyte; > > > > /* Get the sample into sign-magnitude. */ > > sign = ((~sample) >> 8) & 0x80; /* set aside the sign */ [...] > The way the sign is detected is completely braindamaged; it assumes > that signed short is 16 bits wide, so that shifting it 8 bits > to the right will cause the sign bit to land in position 7. It's even more brain damaged than that. It assumes that /int/ is 16 bits. > Also, shifting right a signed quantity whose sign bit is 1 is > implementation-defined; This doesn't matter in this case. The value that the vacated bits take is indeed implementation defined, but the sign bit must reliably be shifted into the required position, since nothing frees it from the requirement that "The result of E1 >> E2 is E1 right-shifted E2 bit positions". > I think it's undefined in C99. No, it isn't. -- Joe Maun Montreal, QC Canada