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

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

Travis Beaty wrote:
> 
> Hello Matt.
> 
> I tried that.  It no longer causes an error as an atom, but I'm still getting 
> a huge positive number as opposed to a negative number, which is what I am 
> expecting.
> 
> I also threw some printf()'s in my C++ code, and it shows those values as 
> being negative. 
> 
> 

Callback values are always treated as unsigned.  To get the negative number, do
this:

constant s4 = allocate(4) -- permanent allocation for speed
function X(MWidget sender, atom x, atom y)

poke4(s4,x)
x = peek4s(s4)

poke4(s4,y)
y = peek4s(s4)

-- x & y are now signed values

.. more code here ..

end function

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

Search



Quick Links

User menu

Not signed in.

Misc Menu