I need to represent a 40-bit binary number. Which C datatype should be used to handle this?
The existing answers are good, but if you want C89 support too, double will be able to store 40-bit integers exactly on all IEEE 754 conformant implementations.
double