Perhaps the prettiest number system of all is the balanced ternary notation1999, Donald Knuth, The Art of Computer Programming, 3rd edition, volume 2, →ISBN, page 207:
Chemistry, Natural sciences, Physical sciences Containing, or consisting of, three different parts, as elements, atoms, groups, or radicals, which are regarded as having different functions or relations in the molecule.
And albeit these thynges be waighty and truthes of great importance, yet (by the infinite goodnes of the Almighty Ternarie,) Artificiall Methods and easy wayes are made, by which the zelous Philosopher, may wyn nere this Riuerish Ida, this Mountayne of Contemplation […] .1570, John Dee, in H. Billingsley (trans.) Euclid, Elements of Geometry, Preface
Although this code is technically correct, you should be cautious when using ternaries. Many developers actually don't like using ternaries because it's easy to miss small details or create quirky behaviors.Richie Miller, Computer Programming Bible: 12 In 1