Reply by robert bristow-johnson September 29, 20152015-09-29
On 9/29/15 4:14 PM, Tim Wescott wrote:
> On Tue, 29 Sep 2015 06:55:30 +0000, glen herrmannsfeldt wrote: > >> Tim Wescott<seemywebsite@myfooter.really> wrote: >>> On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote: >> >> (snip) >> >>>> he was saying "1s complement" (which is the same as "sign-magnitude"), >>>> in which if the truncation is done by masking off the bits, it will >>>> always "round toward zero". but i dunno anybody other than IEEE-754 >>>> that is doing sign-magnitude. >> >> (snip) >> >>> One's compliment and sign-magnitude are not the same:<https:// >>> en.wikipedia.org/wiki/ >>> Signed_number_representations#Signed_magnitude_representation>. >> >> Ones complement is what you get exclusive oring all the non-sign bits >> with the sign bit. In the sense Robert was using it, the result is the >> same. > > I was not arguing with his results, I was just picking nits with his > declaration that one's compliment was the same thing as sign-magnitude. >
and i had a very plain nit.
> They're not.
of course, you're correct, Tim. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by robert bristow-johnson September 29, 20152015-09-29
On 9/29/15 2:55 AM, glen herrmannsfeldt wrote:
> Tim Wescott<seemywebsite@myfooter.really> wrote: >> On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote: > > (snip) > >>> he was saying "1s complement" (which is the same as "sign-magnitude"), >>> in which if the truncation is done by masking off the bits, it will >>> always "round toward zero". but i dunno anybody other than IEEE-754 >>> that is doing sign-magnitude. > > (snip) > >> One's compliment and sign-magnitude are not the same:<https:// >> en.wikipedia.org/wiki/ >> Signed_number_representations#Signed_magnitude_representation>. >
ooops, you're right. i knew that, but i misremembered.
> Ones complement is what you get exclusive oring all the non-sign > bits with the sign bit. In the sense Robert was using it, the > result is the same.
no, i fucked it up, Glen. i conflated 1's comp with sign magnitude. the difference between 1's comp and 2's comp is the number 1.
> > If someone inverted all the bits of a bit representation, would > you consider it the same enough? > >> One's compliment denotes negative numbers by changing the sense of _all_ >> the bits.
1's comp as both +0 and -0. and 1's comp need not worry about the asymmetric overflow from negating 0x8000. that was probably the only 68000 programming trick i learned from Ralph Muha's code at Kurzwiel. very useful trick (with the expense of a tiny bit of deterministic error that you might be able to account for somewhere else in the signal chain) that saves a few instructions.
> Sign-magnitude just sets the sign bit.
and that's what i was thinking and i conflated it with 1's complement. that was a mistake and i should have known better. thanks for the support, Glen. but i goofed it up a little. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by Tim Wescott September 29, 20152015-09-29
On Tue, 29 Sep 2015 06:55:30 +0000, glen herrmannsfeldt wrote:

> Tim Wescott <seemywebsite@myfooter.really> wrote: >> On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote: > > (snip) > >>> he was saying "1s complement" (which is the same as "sign-magnitude"), >>> in which if the truncation is done by masking off the bits, it will >>> always "round toward zero". but i dunno anybody other than IEEE-754 >>> that is doing sign-magnitude. > > (snip) > >> One's compliment and sign-magnitude are not the same: <https:// >> en.wikipedia.org/wiki/ >> Signed_number_representations#Signed_magnitude_representation>. > > Ones complement is what you get exclusive oring all the non-sign bits > with the sign bit. In the sense Robert was using it, the result is the > same.
I was not arguing with his results, I was just picking nits with his declaration that one's compliment was the same thing as sign-magnitude. They're not. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by rickman September 29, 20152015-09-29
On 9/29/2015 6:22 AM, glen herrmannsfeldt wrote:
> rickman <gnuarm@gmail.com> wrote: > > (snip, someone wrote) >>>> One's compliment and sign-magnitude are not the same: <https:// >>>> en.wikipedia.org/wiki/ >>>> Signed_number_representations#Signed_magnitude_representation>. > >>> Ones complement is what you get exclusive oring all the non-sign >>> bits with the sign bit. In the sense Robert was using it, the >>> result is the same. > >>> If someone inverted all the bits of a bit representation, would >>> you consider it the same enough? > >> I literally don't understand the way you are using words. What does >> "same enough" mean? > > The discussion relates to what happens when you shift bits. > > Some bits are zero and some one, but the effect doesn't depend > on what you label the bits. You could label the bits A and B, > or H and L, the logic is the same. If you relabel all the bits > with different labels, the value is the same. > > For similar reasons, an arithmetic right shift of ones complement > (shift all bits and duplicate the sign) and arithmetic right shift of > sign magnitude (keep the sign bit, shift the rest, zero fill) > will give the same numerical result, both different from the numerical > result of an arithmetic right shift of a twos complement value. > > The easiest way to build a sign magnitude adder is to exclusive OR > the sign bit with all the data bits, to convert to ones complement, > use a ones complement adder, then convert (exclusive OR) back.
Now I'm really lost. Nowhere until now has anyone mentioned shifting bits. The discussion was about Quantization Error of 1's complement numbers. I didn't understand what you were trying to say about one's complement and now you take a left turn into shifting data. -- Rick
Reply by glen herrmannsfeldt September 29, 20152015-09-29
rickman <gnuarm@gmail.com> wrote:

(snip, someone wrote)
>>> One's compliment and sign-magnitude are not the same: <https:// >>> en.wikipedia.org/wiki/ >>> Signed_number_representations#Signed_magnitude_representation>.
>> Ones complement is what you get exclusive oring all the non-sign >> bits with the sign bit. In the sense Robert was using it, the >> result is the same.
>> If someone inverted all the bits of a bit representation, would >> you consider it the same enough?
> I literally don't understand the way you are using words. What does > "same enough" mean?
The discussion relates to what happens when you shift bits. Some bits are zero and some one, but the effect doesn't depend on what you label the bits. You could label the bits A and B, or H and L, the logic is the same. If you relabel all the bits with different labels, the value is the same. For similar reasons, an arithmetic right shift of ones complement (shift all bits and duplicate the sign) and arithmetic right shift of sign magnitude (keep the sign bit, shift the rest, zero fill) will give the same numerical result, both different from the numerical result of an arithmetic right shift of a twos complement value. The easiest way to build a sign magnitude adder is to exclusive OR the sign bit with all the data bits, to convert to ones complement, use a ones complement adder, then convert (exclusive OR) back. -- glen
Reply by ArunPrakash September 29, 20152015-09-29
Thanks tim and Thank u all for ur response..
---------------------------------------
Posted through http://www.DSPRelated.com
Reply by ArunPrakash September 29, 20152015-09-29
>I wonder, > >How could the quantization (by truncation) error, E, for negative >fractional numbers represented using ones complement is bounded by 0 <=
E
>< 2^-b ? (i.e, the error is positive) > >For ex, with (b+1) bits (b=3 for magnitude, and 1 bit for sign) > >Using 1s complement the number, X = -(1/8) is represented in binary as
X(1.110). If it is truncated to 1 bit , then X=(1.1), which is in decimal
>equals -(3/8). Therefore the error is given by > > E = Q(X) - X; > > E = -3/8 +1/8 = -(2/8) > >which is in contradiction with the error bound for negative fractional >numbers using ones complement representation. > >Reference: Digital Signal Processing by Oppenheim & Schafer > >Thank you. > > >--------------------------------------- >Posted through http://www.DSPRelated.c
Ya, i got it. Thanks tom, Actually i made an assumption that, the negative number x=(1.100) is same as x=(1.1) without even verifying it. Because such an assumption is true for positive numbers. For ex, x=(0.100) is same as x=(0.1) which is 1/2 in decimal. --------------------------------------- Posted through http://www.DSPRelated.com
Reply by rickman September 29, 20152015-09-29
On 9/29/2015 2:55 AM, glen herrmannsfeldt wrote:
> Tim Wescott <seemywebsite@myfooter.really> wrote: >> On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote: > > (snip) > >>> he was saying "1s complement" (which is the same as "sign-magnitude"), >>> in which if the truncation is done by masking off the bits, it will >>> always "round toward zero". but i dunno anybody other than IEEE-754 >>> that is doing sign-magnitude. > > (snip) > >> One's compliment and sign-magnitude are not the same: <https:// >> en.wikipedia.org/wiki/ >> Signed_number_representations#Signed_magnitude_representation>. > > Ones complement is what you get exclusive oring all the non-sign > bits with the sign bit. In the sense Robert was using it, the > result is the same. > > If someone inverted all the bits of a bit representation, would > you consider it the same enough?
I literally don't understand the way you are using words. What does "same enough" mean? -- Rick
Reply by glen herrmannsfeldt September 29, 20152015-09-29
Tim Wescott <seemywebsite@myfooter.really> wrote:
> On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote:
(snip)
>> he was saying "1s complement" (which is the same as "sign-magnitude"), >> in which if the truncation is done by masking off the bits, it will >> always "round toward zero". but i dunno anybody other than IEEE-754 >> that is doing sign-magnitude.
(snip)
> One's compliment and sign-magnitude are not the same: <https:// > en.wikipedia.org/wiki/ > Signed_number_representations#Signed_magnitude_representation>.
Ones complement is what you get exclusive oring all the non-sign bits with the sign bit. In the sense Robert was using it, the result is the same. If someone inverted all the bits of a bit representation, would you consider it the same enough?
> One's compliment denotes negative numbers by changing the sense of _all_ > the bits. Sign-magnitude just sets the sign bit. So 1000b in 4-bit > one's compliment is -7, while 1000b in 4-bit sign-magnitude is -0. In > the complimentary case, 1111b in 4-bit one's compliment is -0, while > 1111b in 4-bit sign-magnitude is -7.
-- glen
Reply by Tim Wescott September 28, 20152015-09-28
On Mon, 28 Sep 2015 19:19:50 -0400, robert bristow-johnson wrote:

> On 9/28/15 6:13 PM, Tim Wescott wrote: >> On Mon, 28 Sep 2015 12:43:32 -0500, ArunPrakash wrote: >> >>> I wonder, >>> >>> How could the quantization (by truncation) error, E, for negative >>> fractional numbers represented using ones complement is bounded by 0<= >>> E< 2^-b ? (i.e, the error is positive) >>> >>> For ex, with (b+1) bits (b=3 for magnitude, and 1 bit for sign) >>> >>> Using 1s complement the number, X = -(1/8) is represented in binary as >>> X= >>> (1.110). If it is truncated to 1 bit , then X=(1.1), which is in >>> decimal equals -(3/8). Therefore the error is given by >>> >>> E = Q(X) - X; >>> >>> E = -3/8 +1/8 = -(2/8) >>> >>> which is in contradiction with the error bound for negative fractional >>> numbers using ones complement representation. >>> >>> Reference: Digital Signal Processing by Oppenheim& Schafer >> >> So, are you saying that O&S says that quantization by truncation in >> negative ones-compliment numbers is positive, while your own experience >> says it's negative? >> >> If X=(1.1) is a two-bit ones-compliment number, then in decimal X = -0 >> (because X=(0.0) is +0, and thus X=(1.1) is -0). So I'm not so sure >> about your analysis. >> >> > he was saying "1s complement" (which is the same as "sign-magnitude"), > in which if the truncation is done by masking off the bits, it will > always "round toward zero". but i dunno anybody other than IEEE-754 > that is doing sign-magnitude. > > normally, for quantization, it works consistently for positive or > negative values. masking off bits of 2s-complement numbers will always > round down. then the quantization error is always non-negative and less > than the quantized LSB. > > if the OP is working with (IEEE) floating-point numbers and is > quantizing, he/she probably needs to use the floor() function or an > equivalent.
One's compliment and sign-magnitude are not the same: <https:// en.wikipedia.org/wiki/ Signed_number_representations#Signed_magnitude_representation>. One's compliment denotes negative numbers by changing the sense of _all_ the bits. Sign-magnitude just sets the sign bit. So 1000b in 4-bit one's compliment is -7, while 1000b in 4-bit sign-magnitude is -0. In the complimentary case, 1111b in 4-bit one's compliment is -0, while 1111b in 4-bit sign-magnitude is -7. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com