From: Dr. Gary Nelson <gnelson@qu...>  20081224 23:14:06

Arnoud Onnink wrote: >> In it I have made an attempt to outline a computational model for fixing >> "inversed polarity clipping" (for lack of a better name), where a clipped >> signal turns negative. The binary values of samples are encoded in 2complement with the most significant bit being the signbit  1 ==> negative, 0 ==> positive. The largest positive number is 0111 1111 1111 1111 or 32767 in integer format. If you add ONE to that number you get 32768 or 1000 0000 0000 0000 which is a negative number. So it is totally normal to get this rather awful result that clipping creates negative numbers. To finish the story, we convert a positive binary number to negative by inverting all bits and adding one. 0000 0000 0000 0111 is +7 in integer format. To create 7 we invert 1111 1111 1111 1000 and add + 1 1111 1111 1111 1001 is 7 in 2's complement It is necessary that +7 +(7) = 0 0000 0000 0000 0111 1111 1111 1111 1001  0000 0000 0000 0000 so 2's complement works The max negative number is 0111 1111 1111 1111 ,inverted becomes 1000 0000 0000 0000 +1 1 1000 0000 0000 0001 is negative max As an exercise, you can add positive max to negative max and get zero. Gary Nelson Port Townsend, WA 