RE: not_bits() not_working()
- Posted by rforno at tutopia.com Jun 27, 2003
- 433 views
The bit functions are in Eu (and Assembly, C, etc.) to use individual bits, not their "global" meaning. So, you can compress 31 yes - no data in a single integer, for example. Assume you have a big file, each record containing an identifier from 1 to 1,000,000,000. You want to scan the file and find which identifiers are missing and which are duplicated. Using a sequence occupying ~ 256Mb, you can get the job done by reading the file only once, if you flag each identifier by means of the corresponding bit in the sequence. Regards. ----- Original Message ----- From: Al Getz <Xaxo at aol.com> To: EUforum <EUforum at topica.com> Sent: Thursday, June 26, 2003 4:07 PM Subject: RE: not_bits() not_working() > > > Matt Lewis wrote: > > > > > > Al Getz wrote: > > > > > 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? > > > > Actually, it is. not_bits() works exactly as it says it does (although > > it does seem odd): > > > > "Results are treated as signed numbers. They will be negative when the > > highest-order bit is 1." -- Refman > > > > So the bits are correct. The quickest way to convert to unsigned (if > > that's what you want) seems to be to have 4-bytes allocated and do a > > poke4/peek4u after not_bits. (I just tested this vs adding 2^32 and vs > > using xor_bits against a constant equal to 2^32-1). (These were tested > > with Win2K, P3, 1.1GHz) > > > > If you printf with %x (hex formatting) or use int_to_bits, you'll see > > that the bits are correct. > > > > Matt Lewis > > > > Hello Matt, > > I have been using poke4 and peek4u to convert because it seems > to be the most reliable way to do it with only three ops, however > now ill have to check out Carls idea too. There is a chance that > my argument will always be positive. > > I just cant help wondering why not_bits() doesnt work the way > the other _bits functions work, or did i miss something? > Is there any real use for getting a return value of -3 for > not_bits(2) out there? anyone? > > Take care, > Al > > > > TOPICA - Start your own email discussion group. FREE! > >