Two's compliment of -5

Answers were Sorted based on User's Feedback



Two's compliment of -5..

Answer / vignesh1988i

first write the given number in it's binary format.
am considering only 8 bit at a time ,
5- 0000 0101
step 1: convert this binary format to one's compliment (ie)
change 0 to 1 and 1 to 0.
1111 1010

step 2: add 1 to the above binary format.

1111 1010
1
-----------
1111 1011

so this binary format will get stored in memory and the sign
bit will be set to 1.

always the negative number will be stored only in 2's
compliment..........


thank u

Is This Answer Correct ?    20 Yes 2 No

Two's compliment of -5..

Answer / ramprasad g

ans: +5

-5 will be stored as 2's complement of 5
2's complement of -5, is thus 2 times 2's complement of 5.
so the ans is 5 itself.

Is This Answer Correct ?    11 Yes 0 No

Two's compliment of -5..

Answer / ataraxic

Or in other words
~5+1

Is This Answer Correct ?    6 Yes 3 No

Two's compliment of -5..

Answer / vadivel t

2's compliment of a -ve no is, positive value of the same
no.

#include<stdio.h>
#include<conio.h>
void main()
{
int no1, res;
printf("ENTER THE NEGATIVE NO: \n");
scanf("%d", &no1);
no1 = ~(no1);
res = no1 | 0x01;
printf("\nRESULT: %d", res);
getch();
}

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More C Interview Questions

simple c program for 12345 convert 54321 with out using string

7 Answers   TCS,


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

0 Answers  


How can you pass an array to a function by value?

0 Answers  


Are there any problems with performing mathematical operations on different variable types?

0 Answers  


What does emoji p mean?

0 Answers  






When was c language developed?

0 Answers  


What is a union?

0 Answers  


#include<stdio.h> #include<conio.h> # define swap(a,b) temp=a; a=b; b=temp; void main( ) { int i, j, temp; i=5; j=10; temp=0; if( i > j) swap( i, j ); printf( "%d %d %d", i, j, temp); }

9 Answers   Burning Glass,


why do we use pointer instead directly acessing the data?

2 Answers  


what is the syallabus of computer science students in group- 1?

0 Answers  


What is the hardest programming language?

0 Answers  


Can we replace the struct function in tree syntax with a union?

0 Answers   Huawei,


Categories