in Programming in C
447 views
1 vote
1 vote

How the output of the given code is-

How are the binary bits flipping? 

in Programming in C
447 views

1 comment

Never use Turbo C for programming !!
3
3

1 Answer

2 votes
2 votes
Best answer

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
by

3 Comments

why have u multilpied with 84??
0
0

@Akriti

Is it good now?

It was because after the maximum limit the integer gets back to $0$. So I was trying to find where it would stop. (After how many multiples would the resulting number be less than $65536$). But I realize that this way is much better. 

0
0
yes..much better now..thankyou :)
0
0

Related questions