desgin
Full Member level 1
Hello All,
I want to convert long integer to (long)Binary and then separate each bit from my (long data type)Binary number into 8 long variables.
Not able to get correct output by below code, First tried in C (with Online compiler).
Please help me!
I want to convert long integer to (long)Binary and then separate each bit from my (long data type)Binary number into 8 long variables.
Not able to get correct output by below code, First tried in C (with Online compiler).
Please help me!
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include <stdio.h> void main() { long num=95,remainder, base = 1, binary = 0; while (num > 0) { remainder = num % 2; binary = binary + remainder * base; num = num / 2; base = base * 10; } printf("Its binary equivalent is = %ld\n", binary); binary >> 7; binary & 1; printf("New Binary: = %ld\n", binary); }
Last edited by a moderator: