The reason the file contains 5 Bytes of information is because the text (String) '65535'
that you typed in is five characters long.
Each of those characters is very common, a digit, and is part of the infamous character set called ASCII.
Each character in ASCII is exactly 1 Byte long. Thus '65535'
is 5 Bytes long.
Now if you want to represent the integer 65535
just as a number in memory then technically you would only need 2 Bytes yes. Many programming languages do have a data type specifically for that, typically called something like UInt8UInt16
or UShort
.
In short, the difference is in storing a number as text (String) vs as an Integer in memory.