X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Sender: qpaz From: al davis To: geda-user AT delorie DOT com Subject: Re: [geda-user] Wav to C array ~ 16 bit to 12 bit Date: Sat, 29 Mar 2014 16:48:16 -0400 User-Agent: KMail/1.13.7 (Linux/3.2.0-4-amd64; KDE/4.8.4; x86_64; ; ) References: <201403291603 DOT 19284 DOT ad252 AT freeelectron DOT net> <53372E3F DOT 1040704 AT buffalo DOT edu> In-Reply-To: <53372E3F.1040704@buffalo.edu> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201403291648.16993.ad252@freeelectron.net> Reply-To: geda-user AT delorie DOT com On Saturday 29 March 2014, Stephen R. Besch wrote: > On 03/29/2014 04:03 PM, al davis wrote: > > On Saturday 29 March 2014, Stephen R. Besch wrote: > >> realizing that I had forgotten > >> about the sign bit it became clear that you cannot just > >> toss the high bits - you need to toss the low bits > >> (essentially an integer divide by 16). > > > > Usually if numbers are small enough, you can toss the high > > bits. > > > > "Usually" means the usual two's complement representation. > > True enough as long as they are all positive. With signed > data, you really have no choice but division of some kind True even with negative numbers, assuming the usual "two's complement" representation. Even with other representations the conversion is usually simple. If the number is "small enough" and positive, the high bits are all zero. If negative, the high bits are all 1, and after tossing the high bits are still all 1.