CSC 340
CSC 340
Very good job explaining “What is overflow?” I like how you pointed
out that “An overflow happens when you try to store a number or value
that is too large for the number of bits that you have allocated for
storage.”
I especially like how you reinforced that definition with this example:
3-bits can store values from 0 to 7
4-bits can store values from 8 to 15
And you want to add the following numbers using an allocated storage
of 4-bits:
0111 (7)
+1110 +(14)
1 0101 (21)
In my own post, I summed up overflow as being: a situation that
occurs when the result of an arithmetic operation exceeds the
maximum or minimum value that can be represented by the data type
used to store the value. (i.e., when the magnitude of a number
exceeds the range allowed by the size of the bit field).
That begs the question of “how can it be detected?” I offered that
Overflow can be detected by examining the result of an arithmetic
operation and comparing it to the maximum or minimum value that can
be represented by the data type used. If the result is larger than the
maximum value or smaller than the minimum value, an overflow has
occurred.
Best
Dan