# Division by two facts for kids

In mathematics, **division by two** is when a number is divided by two. Some cultures, like the ancient Egyptians, thought this was a different operation than division. Some mathematicians up until the 16th century (1500-1599) thought this too. Today division by two is handled specially in modern computer programming.

Division by two is also called **halving**, **mediation**, and **dimidiation**.

## Binary

In a binary number system, there are only two digits: 0 and 1. All other numbers are represented with those two digits. For example, "one" is 1, "two" is 10, "three" is 11, "four" is 100, and so on. Most of the time people use a number system with ten digits (the numbers 0 through 9.) This is called the decimal number system.

Division by two in binary is very easy. It is done by dropping the last digit on the right of the number. This is called a "bit shift operation." For example, if we performed a bit shift operation on the binary number 100, we'd get 10. Since binary 100 is decimal 4, and binary 10 is decimal 2, this makes sense.

Another example is performing a bit shift operation on 1101. This would leave us with 110, but we dropped a 1 from the end, not a zero. This also makes sense because 1101 in binary is 13 in decimal. If we divide 13 by 2, we get 6 with a remainder of 1 (we have 1 left over.)

### Computers

*See also: Bit*

Computers use the binary number system to store information. Information is broken up into tiny pieces called *bits*. Each bit is either a 0 or a 1. Because of this, the fastest and easiest way for a computer to do division is by a bit shift operations -- division by two. Replacing regular division with bit shifts is a way to do program optimization. (Program optimization is trying to make a program faster and more efficient.)

In computer programming, the symbol `>>`

is sometimes used to show a bit shift operation. In Java, we can ask the computer to do the problem by writing `19 >> 2`

. This is the same as writing `19/2`

. Both of these versions will give us the answer `9`

. There is a problem when trying to do something a problem like . In Java, if we write `-3/2`

, the computer will tell us the answer is `-1`

. But if we try to do `-3 >> 2`

, the computer will say the answer is `-2`

. This will happen every time we try to do a bit shift operation with one negative number. The reason for this is complicated, and has to do with the way negative binary numbers are saved by the computer.

Even though it is fastest for computers to do division using bit shift operations, most computer code does not do it this way. This is because programmers want their programs to be *portable* and *readable*. Portable means that a program can be run on many different kinds of computers and operating systems. Readable means that the source code is easy to read and understand. Most of the time, the compiler (a program that changes source code into 0's and 1's that the computer can understand) will change the division into bit shifts automatically.

*Kiddle Encyclopedia.*