Division by two


Division by two is simple in even-numbered bases.

NOTE: The following methods return only the integer part of the result. No fractions, decimals, or remainders will be returned.

In binary, just shift one place to the right. (Example: 1101001 changes to 110100)

The following algorithm is for decimal. However, it can be used as a model to construct an algorithm for taking half of any number N in any even base.

<table border="1" cellspacing = "0" cellpadding="2"> <tr><th>If first digit is</th> <td>Even</td><td>Even</td><td>Even</td><td>Even</td><td>Even</td> <td>Odd</td><td>Odd</td><td>Odd</td><td>Odd</td><td>Odd</td> </tr> <tr><th>And second digit is</th> <td>0 or 1</td><td>2 or 3</td><td>4 or 5</td><td>6 or 7</td><td>8 or 9</td> <td>0 or 1</td><td>2 or 3</td><td>4 or 5</td><td>6 or 7</td><td>8 or 9</td> </tr> <tr><th>Write</th> <td>0</td><td>1</td><td>2</td><td>3</td><td>4</td> <td>5</td><td>6</td><td>7</td><td>8</td><td>9</td></tr></table>

Example: 1738/2=?

Write 01738. We will now work on finding the result.

From the example we can see that 0 is even.

If the last digit of N is odd digit add .5 to the result.