bitand, bitor

Enrico Segre enrico.segre at weizmann.ac.il
Wed Feb 6 10:46:28 CET 2008


Hi there,
the recent bug activity about bitand, bitor & the like made me wonder
and look a bit into the functions themselves. Maybe I miss something,
but why at all does one need these contraptions? As they are written,
besides argument parsing, now these functions use an absurd detour via
converting their arguments to "binary" string, then to ascii codes, then
make string substitutions, then again convert back to floats - all this
is certainly not performant. Why can't one just use int32(x) &
int32(y)? 
Is there a consideration of MAXINT? (a float can represent a 52bit
integer without loss of precision, which is more than 32bit -- consider
dec2hex(2^53+[-2:2]) But even then, that could be treated appropriately
without waiting for int64, say, with

a=2^32
z=double(int32(x/a) & int32(y/a))*a 
z=z+double(int32(x-z) & int32(y-z))

Enrico 




More information about the dev mailing list