How is short different from int? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How is short different from int?

There's no actual change in the memory either of these take, so what's the difference? What situation can I use short in that I can't solve with int? Thanks

15th Apr 2017, 12:09 PM
Naman Khilrani
Naman Khilrani - avatar
2 Answers
+ 24
What we have in c#: value of short (16bit): -32,768 to 32,767 value of int (32bit): -2,147,483,648 to 2,147,483,647 and here is possible answer to c++ question: http://stackoverflow.com/questions/24371077/when-to-use-short-over-int
15th Apr 2017, 12:40 PM
Illusive Man
Illusive Man - avatar
0
The size of a variable depends on the system. It just happens that in your system, the size of a short and an int is the same.
15th Apr 2017, 2:02 PM
Denis Felipe
Denis Felipe - avatar