+ 2
How is it possible for int to store 6 numbers?
I have seen on net that int can only store 4 bytes but I have tried it practically and it stored 6 numbered digit also,Why does this happen?
4 Respostas
+ 5
Your concrete example could be stored in long (or java.lang.Long if this is necessary).
If at any point you need bigger numbers, you can try java.math.BigInteger (if integer), or java.math.BigDecimal (if decimal)
+ 4
You're using the words "bytes" and "numbers" as if they're the same thing, which they aren't. Bytes is referring to the memory storage unit, which is quite different. There are 8 bits in a byte, and in this case you're working with 4 bytes, which gives you 32 bits to make up the numbers you're wanting. In regards to numbers, 32 bits gives you room to do a lot (billions?).
Anyways, your best means of understanding this is to better understand memory and how its units work (and why). If nothing more, I'm sure there are millions of charts in the online world that has this mapped out.
+ 2
1byte=8bits
4bytes=32bits
Store in binary can have 32 "0"or "1" one bit mark + -
32-1=31bits
int: -2^31~0~2^31-1