Re: My Bits are Flipping (or, "Why Can't I Be Negative?")

new topic     » goto parent     » topic index » view thread      » older message » newer message

Juergen Luethje wrote:
> 
> Travis Beaty wrote:
> 
> > Well, actually, that's the problem.  The value will be positive if the mouse
> > is *in* the widget, but will become negative if it crosses past the left or
> > top edge.
> 
> And what is the problem? Andy wrote about signed values. "signed" does
> not mean, that the concerning values only can be negative. "signed"
> values can be negative or positive.
> 
What he said.  The proposed conversion will not affect your positive values
because the representation for unsigned positive values and signed positive
values is the same (assuming 32-bit values) as long as the value is in the range
[0,2147483647].

The ranges will be mapped like this:
unsigned [0,2147483647] => signed [0,2147483647] (sign is +)
unsigned [2147483648,4294967295] => signed [-2147483648,-1] (sign is -)

Please try it, I believe it will do exactly what you want, and the overhead is
very little (and unavoidable anyway).



Press Enter...

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu