eli5: Type casting

612 views

casting of larger variable to smaller variable results in the modulo of larger variable by the range of smaller variable.

I mean seriously explain it like I’m 5

In: Other

2 Answers

Anonymous 0 Comments

Say the larger type allows numbers from 0 to 9999 and the smaller only 0 to 99.

Then if the variable with large type has value 287, after type casting to the smaller type, it becomes 87. Other example: 345 becomes 45, 66 remains 66. Essentially the modulo means the amounts “over” the max value of the smaller type is lost.

You are viewing 1 out of 2 answers, click here to view all answers.