O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Around the Bases

You can represent the number fifteen in base ten as 1510, in base nine as 169, in base 8 as 178, in base 7 as 217. Why 217? In base 7 there is no numeral 8. In order to represent fifteen, you will need two sevens and one 1.

How do you generalize the process? To convert a base ten number to base 7, think about the columns: in base 7 they are ones, sevens, forty-nines, three-hundred forty-threes, and so on. Why these columns? They represent 70, 71, 72, 74, and so forth. Create a table for yourself:

4 3 2 1
73 72 71 70
343 49 7 1

The first row represents the column number. The second row represents the power of 7. The third row represents the decimal value of each number in that row.

To convert from a decimal value to base 7, here ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required