c++ - How to get long from int -
how long
value of int
? example how long value of -127?
if talking bit representation negative numbers having leading 1, use:
int intvalue = -127; long longvalue; if((0x80 << (sizeof(int)-1)) & intvalue) { longvalue = (0x80 << ((sizeof(long)-1)*8)) | ((0x80 << ((sizeof(int)-1)*8)) ^ intvalue); }else{ longvalue = intvalue }
i hope did not mess brackets.
Comments
Post a Comment