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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -