Untitled
raw download clone
C
views 47
,
size 574 b
#include<stdio.h>
void binary(unsigned int i){
    if( i != 1 ) binary(i/2);
  	printf("%u", i%2 );
}
int main( ){
    float x;
    scanf("%f", &x);
    void *ptr = (void*)&x;
    unsigned int out = *((unsigned int*)ptr);
    //printf("%d\n", out);
    if(x==0) printf("00000000000000000000000000000000");
    if(x>1){
        printf("0");
        binary(out);
        printf("\n");
    }
    else if(0<x && x<=1){
        printf("00");
        binary(out);
        printf("\n");
    }
    else{
        binary(out);
        printf("\n");
    }
}
close fullscreen
Login or Register to edit or fork this paste. It's free.