CIS3355:
Business Data Structures |
What are unsigned integers ?? As we have seen before, by default, all numeric values are stored with a sign-bit. However, there may be times when I want to store values which can not be negative. Some examples of integers which are always non-negative are:
If I specifically declare that I want to store a variable as unsigned then no sign-bit will be included; ALL of the bits will be used to store the value (meaning that we will be able to represent numbers twice as large as we could with the sign-bit). For example, suppose that I want to store values on 8-bits:
Wait!! You mean the bit sequence 10110100 can mean either the value 180 or -76 ?? Absolutely. How do I know which value is stored? You basically have to be told what type of data is stored at a location, and how it should be interpreted. After all, what we are really dealing with is a series of light switches. It is our interpretation of what those light switches mean that give us information. Nothing has really changed since our first tutorial.
|