Re: My Bits are Flipping (or, "Why Can't I Be Negative?")
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Aug 27, 2004
- 458 views
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