0
How external type casting works in java?
Can anyone explain me how external type casting exactly works. Actually while reading a book of java I couldn't understand the following text " if the size of whole number is too large to fit into the target integer type, then value will be reduced modulo the target type's range" please can anyone explain me this thing with an example.
1 Resposta
+ 5
let's imagine that the type Int can only fit numbers from -10 to 10
if you try to put 23 into the type int (which now only stores numbers <=10) the computer will do this: 23(your number)%10 (max storage) = 3
that way the number 3 will be stored in you variable
if course the type int is able to store much higher numbers, I just used 10, so it's easier to understand
hope this helps ^^