devxlogo

converting a 64 bit number from little indian to big indian

converting a 64 bit number from little indian to big indian

#includelong long int INT_little_endian_TO_big_endian(long long int i){ return (((i&0xff)8)&0xff000000)|((i24)&0xff0000)|((i40)&0xff00)|((i56)&0xff));}int main(){ long long int num = 1,rev; if(*(char *)&num == 1) //if num is odd,compare with 1 other wise compare with 0{ printf(”
Little-Endian
“); printf(“%d”,sizeof(num));}else { printf(“Big-Endian
“);}rev=INT_little_endian_TO_big_endian(num);printf(“%lld
“,rev);return 0;}

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist