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. 
> 

Oh, yeah, I remember this now.  Euphoria call_backs are always unsigned.
Here's what I've done where I've had this problem.  I call the below 
function on any parameters that need to be signed:

constant sptr = allocate(4)
function signed( atom unsigned )
	poke4(sptr,unsigned)
	return peek4s(sptr)
end function


Matt Lewis

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

Search



Quick Links

User menu

Not signed in.

Misc Menu