Bitboards using 2 DOUBLE's??
Posted: Tue Jun 02, 2009 2:47 am
Here's a questions that popped into my head the other day...
Is it possible to do bitboards using two 64 bit (53 bit mantissa) DOUBLE variables?
Without undo conversion to / from integer, of course. (Pretend conversion is difficult so it's best to avoid it if at all possible.)
I know several people have developed math packages that create a fake 128 bit (106 bit mantissa) 'quad' or 'double double' math package. So it is possible to do a lot of things if you want to be creative. (I know from experience those packages tend to be fragile, though. Most were written for non-PC FORTRAN where a 64 bit float really is 64 bits, unlike on Windows where it can be 64 bits or 80 bits or even change without your knowledge. I've had that happen. A whole lotta fun to debug a math package when you don't know your precision is changing behind your back!)
1) Setting & clearing of bits. Not too hard provided you assume the bits are in a known state. So you don't try to set a bit already set, for example. It'd just be addition & subtraction.
2) Clear specific bits. Can be done. Multiply by some huge value to make the lower bits underflow, then divide by it and add back the other bits you forced off. Clumsy, but I've done things like that before. It used to be done as a quick way to convert a double to integer because floor() was so slow.
3) XOR for the Zobrist hash. Don't think so. Although with 106 bits of mantissa, you might be able to make do with just adding & subtracting 80+ bit numbers. I suppose a single DOUBLE could work tolerably well provided the numbers don't get so big you start getting round-off errors.
4) Bit counting. I don't know...
5) Find first / next / last bit. Not easy. At least not in a convenient way. Right off hand, I can't think of any reasonable way.
6) Magic attacks... I'd say you probably could do the Kindergarten stuff but anything else might be too complicated.
7) Bit-Ops. AND & OR. Pretty hard, I think. (My way of saying not possible....)
8) And what else....?
I know it wouldn't actually be practical.
As I said, it was just something that popped into my head the other day and I started getting really curious.
Any thoughts on this?
Carey
Is it possible to do bitboards using two 64 bit (53 bit mantissa) DOUBLE variables?
Without undo conversion to / from integer, of course. (Pretend conversion is difficult so it's best to avoid it if at all possible.)
I know several people have developed math packages that create a fake 128 bit (106 bit mantissa) 'quad' or 'double double' math package. So it is possible to do a lot of things if you want to be creative. (I know from experience those packages tend to be fragile, though. Most were written for non-PC FORTRAN where a 64 bit float really is 64 bits, unlike on Windows where it can be 64 bits or 80 bits or even change without your knowledge. I've had that happen. A whole lotta fun to debug a math package when you don't know your precision is changing behind your back!)
1) Setting & clearing of bits. Not too hard provided you assume the bits are in a known state. So you don't try to set a bit already set, for example. It'd just be addition & subtraction.
2) Clear specific bits. Can be done. Multiply by some huge value to make the lower bits underflow, then divide by it and add back the other bits you forced off. Clumsy, but I've done things like that before. It used to be done as a quick way to convert a double to integer because floor() was so slow.
3) XOR for the Zobrist hash. Don't think so. Although with 106 bits of mantissa, you might be able to make do with just adding & subtracting 80+ bit numbers. I suppose a single DOUBLE could work tolerably well provided the numbers don't get so big you start getting round-off errors.
4) Bit counting. I don't know...
5) Find first / next / last bit. Not easy. At least not in a convenient way. Right off hand, I can't think of any reasonable way.
6) Magic attacks... I'd say you probably could do the Kindergarten stuff but anything else might be too complicated.
7) Bit-Ops. AND & OR. Pretty hard, I think. (My way of saying not possible....)
8) And what else....?
I know it wouldn't actually be practical.
As I said, it was just something that popped into my head the other day and I started getting really curious.
Any thoughts on this?
Carey