Untitled
raw download clone
CPP
views 11
,
size 438 b
#include<stdio.h>
int A[32];float x;
int main(void)
{while(1){
    
    scanf("%f",&x);
    void *ptr = (void*)&x;
    int out = *((int*)ptr);
    if(out<0)
    {
        A[0]=1;out=out*(-1);
    }
    else
    {
        A[0]=0;
    }
    for(int i=31;i>0;i--)
    {
        A[i]=out%2;
        out=out/2;
    }
    for(int i=0;i<32;i++)
    {
        printf("%d",A[i]);
    }
    printf("\n");
}
return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.