1. not_bits() not_working()
- Posted by Al Getz <Xaxo at aol.com> Jun 26, 2003
- 505 views
Hello, I've found that Euphorias not_bits() function doesnt really work correctly. For example: 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? Take care for now, Al
2. Re: not_bits() not_working()
- Posted by "Carl W." <euphoria at cyreksoft.yorks.com> Jun 26, 2003
- 474 views
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 ]
3. Re: not_bits() not_working()
- Posted by rolf at rschr.de Jun 26, 2003
- 490 views
Al Getz wrote: > atom a,x > a=2 > > x=not_bits(a) > > --now x equals -3, which isnt correct. It is correct! look at this (or try it yourself): --------------------------------------------------- printf(1,"%08x\n", 2 ) -- 00000002 printf(1,"%08x\n", not_bits(2) ) -- FFFFFFFD --------------------------------------------------- Please notice also: 0000 0000 0000 0000 0000 0000 0000 0010 = 2 = #00000002 1111 1111 1111 1111 1111 1111 1111 1101 = -3 = #FFFFFFFD Have a nice day, Rolf
4. Re: not_bits() not_working()
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 26, 2003
- 448 views
----- Original Message ----- From: "Al Getz" <Xaxo at aol.com> To: "EUforum" <EUforum at topica.com> Subject: not_bits() not_working() > > > Hello, > > I've found that Euphorias not_bits() function doesnt really work > correctly. > > For example: > > 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? > Sorry Al, but it does exactly what I'd expect it to do. Each bit in the 32-bit value is reversed. If it didn't work this way a number of functions in win32lib would fail. -- Derek