cast to 'unsigned long' before using ~ if we need an unsigned long result