458 views
1 votes
1 votes

How the output of the given code is-

How are the binary bits flipping? 

1 Answer

Best answer
2 votes
2 votes

First of all as Kapil already said never use Turbo C.

Now the reason you're getting this answer is as follows:

I think your Turbo C++ is 16 bit version.

Thus the max range you can have of int type is $-2^{15}(32767) \;to\; 2^{15}-1 (-32768).$

Thus your integer rounds to $0$ again after $2^{16}=65536$.

Binary representation of $5565654$ is $10101001110110011010110$. But since the compiler is 16 bit only thus the no. which gets stored is $1110110011010110$ (last 16 bits).  

$1110110011010110=(60630)_{10}$. 

Since the MSB is $1$, this is a negative integer. Take it's 2's complement of $1110110011010110$and you get $-4906$ 

edited by

Related questions

1 votes
1 votes
1 answer
1
tusharb asked Mar 1, 2022
428 views
Suppose we have a 32-bit memory and we have to representunsigned int a = -5What will the memory representation look like?000000…….1011or 111…..1011
2 votes
2 votes
2 answers
4
srestha asked May 13, 2019
959 views
Can someone explain the output of this code? and what (char*) is doing actually?#include<stdio.h struct Ournode{ char x, y, z; }; int main() { struct Ournode p={'1', '0',...