how can i get the last bit of a double

how can i get the last bit of a double?
i want to take a "or" operation with it.
double d; //assign to whatever num you want
char lastbit = d & 0x1;
g++ test.cpp                                                       
test.cpp: In function ‘int main(int, char**)’:
test.cpp:10: error: invalid operands of types ‘float’ and ‘int’ to binary ‘operator&’
char lastbit = d & 0x1;

Nice try but it won't work :P You can't use bitwise operators with doubles or floats.
And what do you mean with 'last bit'? Check this out:

The number is 0.15625 but the 'last bit' (the least significant bit of the fraction part) is zero.
Maybe what you want is the last digit.
Last edited on
Topic archived. No new replies allowed.