Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Negarive numbers in .db statements

2012-03-21 by Jim Wagner

On Mar 21, 2012, at 7:23 AM, David VanHorn wrote:

> On Wed, Mar 21, 2012 at 3:05 AM, STEVEN HOLDER
> <s.holder123@btinternet.com> wrote:
> > David,
> >
> > If you need to change the sign, you could cast the signbit as a signed char and xor with 0x80, which is the sign bit, would that do the trick as not quiet sure what you are trying to do.
> 
> That won't get it for me.
> I'm trying to establish a distortion on some test case data, and I
> need the distortion to be positive or negative..
> In the truncated example I gave, if the distortion is "+3" then the
> values might be something like
> 
> 100,103,97,100
> 
> If the distortion is -3, then the values would be
> 
> 100, 97, 103, 100
> 
> The thing is that I should be able to include a term like (Sign * Var)
> in an addition, and have it work properly.
> 
It depends entirely on how your code uses the data. If you read it into an unsigned int, which is the effective format for most asm code, it will interpret -1 as a positive number. You can't fool it. If your code CAN use negative numbers, as negative, then simply subtract the positive value from zero.

Jim Wagner
Oregon Research Electronics



[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.