--- pnadgir nadgir <[EMAIL PROTECTED]> wrote:

> how is that possible can u explain? how it prints
> whether it is a big endian or little endian
> 
>  
> Guys!,
>  
> See this code
>  
> main()
> {
>    int x=1;
>    if((*(char *)&x)==1)//Little Endian
>    else  //Big endian
> }
>  
> This is much, much easier to understand.
>  
>  


This means that x is typecasted into char and we are
doing the AND operation with 1 i.e

IF BIG ENDIAN M/C is there then the MSB is placed onto
the leftmost part of memory address.. and when it is
typecated to char (that value 1 is lost) and you will
be having zero as a result of and operation..

like 


1stly
(in case of 16bit compilers and BIG ENDIAN M/c)
RIGHT 00000001 MEMADDRESS+0
LEFT 00000000 MEMADDRESS+1
 

After typecasting into char
the x has value
00000000

And when and opertaion is done...
then 
00000000 is the result...

Similary 
For the Little ENDIAN , 16 bit compilers
X memory representation 
LEFT 00000000
RIGHT 00000001


And after typecasting into char
the value of X
00000001

And when AND operation is done..
the value of X is
00000001


This is how you would be getting the result.....


Regards,
Ashwin Mittal.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~-> 

To unsubscribe : [EMAIL PROTECTED]

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4892
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/Programmers-Town/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to