calculate 0101+1001+1 as 1111
Now if the signed numbers are represented using 2's complement system
then 1111 is the representation for -1


On Aug 10, 7:23 pm, Ayswarya Srinivasan <krsayswa...@gmail.com> wrote:
> can someone explain how this works-
> *
> *
> *void* *main*(){
>     *int* a,b,d;
>     scanf("%d%d",&a,&b);
>     d=a+~b+1;
>     printf("%d",d);
>     getch();
>
> }
>
> say if a=5 b=6 then
> output is -1
>
> if ~ is one's complement operator
> then
> a=0101
> ~b=1001
>
> d= 0101+1001+1. which is not -1
>
> can someone explain how it works.
>
> --
>
> Regards,
> Ayswarya S

-- 
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