RE: not_bits() not_working()
- Posted by Al Getz <Xaxo at aol.com> Jun 26, 2003
- 452 views
Carl W. wrote: > > > Al Getz wrote: > > > atom a,x > > a=2 > > > > x=not_bits(a) > > > > --now x equals -3, which isnt correct. > > --x should be equal to the 8 digit hex equivalent of -3, > > --right? > > The *_bits() functions all return negative if the high bit of the result > > is 1. They use signed 32-bit ints internally I presume. > > try: > > function not_bitsU(atom a) -- U = Unsigned > return #FFFFFFFF - a > end function > > or better (but slower): > > constant B32m1 = power(2,32)-1 > function not_bitsU(atom a) -- U = Unsigned > return B32m1 - and_bits(a, B32m1) > end function > > Carl > > -- > [ Carl R White == aka () = The Domain of Cyrek = ] > [ Cyrek the Illogical /\ www.cyreksoft.yorks.com ] > > Hello there Carl, I have been using poke4 and peek4u right after the not_bits(), but i'll also take a look now at your subtraction functions. I think 'a' in my use will always be positive, but ill have to double check first. Thanks for the ideas, Al