float is 4 bytes.
so a=3.75 will be stored in 4 bytes in memory.

the moment you have a pointer referring to the same memory location but type
cast to (char *), the pointer will refer to character i.e. 1 byte.
^^ this explains the p[0] , p[1], p[2], p[3] <- 4 bytes of the 3.75

now finally the o/p
00 00 AC 40
^^ it is in little endian format. i.e the data bytes are stored in memory is
reverse format.

On 20 August 2011 11:21, Vijay Khandar <vijaykhand...@gmail.com> wrote:

> If the binary equivalent of 5.375 in normalised form is - 0100 0000
> 1010 0000 1100 0000 0000 0000
>
> what is the o/p of following code-
> main()
> {
> float a=5.375;
> char *p;
> int i;
> p=(char *)&a;
> for(i=0;i<=3;i++)
> printf("%02X",(unsigned char)p[i]);
> }
>
> O/P= 00 00 AC 40
> Plz, Plz  anyone explain me in detail, how this o/p is coming?
> Vijay..........
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
___________________________________________________________________________________________________________

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers <=> Save Trees

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to