Why is it important to assume that integers in our computer model have a fixed size?
views:
75answers:
4
A:
Do you mean 'assume' or 'know' ?
By the fact that they are fixed size, they are limited to the quantities that they can store. Are you storing a count greater than 65,535 (unsigned 2-byte short), or the population of the Earth (6 billion - greater than a 4-byte unsigned int can store). What you're trying to model will dictate what size of datatype you use.
You can use objects that aren't fixed-size (e.g. BigInteger in Java). The downside is that performance will suffer to some degree.
Brian Agnew
2010-09-18 15:05:50
A:
Because in computer math, a+1 < a
can be true!
If a
is a signed one-byte twos-complement value, it can store numbers from -256 to 255. If a=255
, then a+1=-256
.
Borealid
2010-09-18 15:11:58
Actually, that's -128 to 127, or 0 to 255 if unsigned.
Chris
2010-09-18 16:22:06
A:
An address have a fixed size which is determined by the Operating System and that's an integer number.
Lajos Arpad
2010-09-18 20:10:51