All data stored in modern computers can be reduced down to the smallest component of a data: A bit. A bit is like a switch. Turned off, it stores and shows as a 0, turned on, it shows as a 1. By combining various turned on bits, we can make larger numbers using two’s complement math. This allows us to store numbers, either as is, or modified with various look up features to display text, decimal numbers, etc.
We don’t work with bits, we typically work with bytes, or larger pieces of data made up of multiple bytes. A single byte is made up of 8 bits in most computer systems, and can store a value of 0-255 if unsigned, or -128 to 127 if signed. If you use two bytes, you don’t double the value, but because of two’s complement math, it allows you to do approximately +/- 32,000 or 0-65,000. Four bytes allow for approximately +/- 2 billion.
Most systems put a limit based upon four bytes for an integer number. We’ll learn about integers, decimals (called floating point numbers) and more in future classes.
Below we will let you try out turning on and off bits to make different number values between 0 and 255. Each circle object is a button which will allow you to simulate toggling a bit. By default they are all off.
Value of Selected Bits: