in Programming in C
1,128 views
2 votes
2 votes
#include <stdio.h>
 
int main()
{
    float a=5.375;
    char *p;
    int i;
    p = (char*)&a;
    for(i=0; i<2; i++)
        printf("%x", (unsigned char)(p[i]^p[3-i]));
 
    return 0;
}

Explain in detail
in Programming in C
by
1.1k views

4 Comments

This is not in DETAIL, but it should print two values, first one is $XOR$ of 1st and $4$th Byte of $a$ and second one is $XOR$ of $2$nd and $3$rd Byte of $a$. What we need to do is to figure out the float point representation of $a$ for a $4$ byte container.
0
0

Can you explain how it is XOR ?

0
0
Thanks for link understood.
1
1

1 Answer

7 votes
7 votes
Best answer

Assuming the machine is little endian.

selected by

Related questions