Hi,
How can I convert 0.00 to a binary number. I know how to convert with just the decimal.But how can I convert using a fractional part. I know how to do it on paper but I am having a hard time writing a program for it. Any help is appreciated.
My program that converts decimal to binary:
Code:#include <stdio.h>
void dec_bin(int number);
int main(void) {
int input = 0;
printf("Digit (0-255): ");
scanf("%d", &input);
(input >= 0) && (input < 256) ? dec_bin(input) : exit(1);
return 0;
}
void dec_bin(int number) {
int x, y;
x = y = 0;
for(y = 7; y >= 0; y--) {
x = number / (1 << y);
number = number - x * (1 << y);
printf("%d", x);
}
printf("\n");
}