# How do you do non-whole numbers in bases other than 10?

**URL:** <https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072>\
**Category:** Factual Questions\
**Created:** [May 21, 2008, 4:55am UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072 "2008-05-21T04:55:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [May 21, 2008, 4:55am UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/1 "2008-05-21T04:55:19Z")

</div>

I could probably use a refresher in multiplication/division\* as well, especially since I think fractions may play a big role here. (The internet has been woefully lacking in this knowledge).

How can I represent things in the equivilent to “decimals” in other bases? I’m guessing .5 would be .1 in binary, .4 in octal, and .8 in hexadecimal (the ones I’m mainly interested in), but the more complex representations confuse me. I probably would have a better time if I represented them as fractions (but I can’t do long division in non-decimal either) but that doesn’t help with irrational numbers (i.e., what’s Pi in binary, other than the ratio of the circumference to the diameter of course?) maybe some jury rigged scientific notation could help, I don’t know. What about square root, can you do long square root and exponents in the bases, or rather, how can you?

On a similar note:  
I’d figure with the correct drive and lack of life you could feasibly do complex number calculations (meaning both things involving “i” and things needlessly complicated) in (say) base 13 if you felt like it, but has anyone bothered to do things like this in strange bases? You can explain how if you feel it’s the only way to justify you knowing this, but a simple rundown of who/when/why will do just fine. I’m curious as to how to do it but I figure knowing how will be like watching the video in the ring and kill me in some amount of time if I don’t pass the knowledge on.

_Note: I think I have multiplication, at least in base 2, I’m more confused about things like 7_7 in base 8, at least without cheating by sending it through base 10 and then converting.

Blahblahblah mandatory link (before anyone else does it):

[![]( " - YouTube") ](https://www.youtube.com/watch?v=GAm3KWiDPKU)

---

<div class="post-metadata">

**Author:** ![Voyager](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/voyager/32/133_2.png) [@Voyager](https://boards.straightdope.com/u/Voyager)\
**Post date:** [May 21, 2008, 5:41am UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/2 "2008-05-21T05:41:23Z")

</div>

You can find out how it is done in binary [here](http://cnx.org/content/m10263/latest/) among zillions of other places. Search for binary fractions, numerical analysis, or computer arithmetic. Any CS major learns this - at least we did when I was in school.

You have the basic idea. To read a fraction in any base, say 0.f1,f2,f3, (where the commas are to separate the fis, because I don’t feel like pasting in something with subscripts) by  
0 + f1 \* b^-1, + f2\*b^-2, etc., where b is the base.

That’s fixed point. You also can, and usually do, handle this by making the mantissa be \> 1, and multiplying the whole thing by an exponent - so my example would be expressed as f1f2f3\*b^-3.

You clearly can’t express all fractions exactly in this way, but we can’t in decimal either.

Hope that helps. I never did much like Computer Arithmetic.

Now, as how to do arithmetic, since addition and multiplication are well defined, everything else is done either in software or in hardware, basically the way you’d do it in decimal. Most of computer arithmetic looks for ways of doing operations faster and more precisely. You just have to learn your octal or hex times tables.

---

<div class="post-metadata">

**Author:** ![Voyager](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/voyager/32/133_2.png) [@Voyager](https://boards.straightdope.com/u/Voyager)\
**Post date:** [May 21, 2008, 5:48am UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/3 "2008-05-21T05:48:11Z")

</div>

As for multiplying in base 8, remember how you learned to do it in base 10 - memorization. But I’ve never really had to do that in 40 years.

---

<div class="post-metadata">

**Author:** ![aldiboronti](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@aldiboronti](https://boards.straightdope.com/u/aldiboronti)\
**Post date:** [May 21, 2008, 5:58am UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/4 "2008-05-21T05:58:24Z")

</div>

Here’s [binary pi](http://www.befria.nu/elias/pi/binpi.html) to the first 32768 digits.

Oh, and take care when using binary to represent irrationals. 🙂

> [@](#):
>
> … since most anything can be converted into binary form (hey, it’s how computers work, right?), from word documents, jambalaya recipes, digital pictures, MP3 files, etc, to take the irrational number pi and convert it into binary would theoretically mean that pi contains ALL finite bit strings ever created, therefore by computing pi in binary you would be guilty of the following:
> 
> 1. Copyright infringement (of all books, all short stories, all newspapers, all magazines, all web sites, all music, all movies, and all software, including the complete Windows source code)
> 2. Trademark infringement
> 3. Possession of child pornography
> 4. Espionage (unauthorized possession of top secret information)
> 5. Possession of DVD-cracking software
> 6. Possession of threats to the President
> 7. Possession of everyone’s SSN, everyone’s credit card numbers, everyone’s PIN numbers, everyone’s unlisted phone numbers, and everyone’s passwords
> 8. Defaming Islam. Not technically illegal, but you’ll have to go into hiding along with Salman Rushdie.
> 9. Defaming Scientology. Which IS illegal — just ask Keith Henson.

[Link](http://darkphetus.rayd.org/?p=247)

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [May 21, 2008, 8:35am UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/5 "2008-05-21T08:35:26Z")

</div>

To the best of my knowledge, it has not yet been proven that every finite bit string appears in the binary expansion of pi. People often assume pi, and all other irrational numbers, to be what is technically known as a [“normal number”](http://en.wikipedia.org/wiki/Normal_number) (one whose limiting frequency of containing any particular block of digits is the same as would be expected from a uniformly random distribution), but this has definitely not yet been proven for pi (or e or sqrt(2) or any other familiar number), not even for a single base. Certainly, there are irrational numbers which fail to contain every finite bitstring (for example, the number given in binary by 0.1010010001000010000010000001…, which never contains the bitstring “11”)

---

<div class="post-metadata">

**Author:** ![MikeS](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@MikeS](https://boards.straightdope.com/u/MikeS)\
**Post date:** [May 21, 2008, 2:18pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/6 "2008-05-21T14:18:51Z")

</div>

> [@Jragon](#):
>
> How can I represent things in the equivilent to “decimals” in other bases? I’m guessing .5 would be .1 in binary, .4 in octal, and .8 in hexadecimal (the ones I’m mainly interested in), but the more complex representations confuse me.

As **Voyager** said, in base b the first place beyond the decimal represents b[sup]-1[/sup]; the second represents b[sup]-2[/sup]; and so forth. As an example, in base 3, we have 0.5[sub]10[/sub] = 0.111111…[sub]3[/sub], since 1/3 + 1/9 + 1/27 + … = 1/2.

[QUOTE=Voyager]  
As for multiplying in base 8, remember how you learned to do it in base 10 - memorization. But I’ve never really had to do that in 40 years.  
[/QUOTE]  
To expand on this, you’d just memorize the base-7 multiplication table:

```auto

   1 2 3 4 5 6
--------------------
1| 1 2 3 4 5 6
2| 2 4 6 11 13 15
3| 3 6 12 15 21 24
4| 4 11 15 22 26 33
5| 5 13 21 26 34 42
6| 6 15 24 33 42 51

```

Beyond this, if you wanted to multply larger numbers together, you’d use the same algorithm you do in base 10 — only with more carrying:

```auto

  42
  25
----
 303
114
----
1443

```

---

<div class="post-metadata">

**Author:** ![Bytegeist](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@Bytegeist](https://boards.straightdope.com/u/Bytegeist)\
**Post date:** [May 21, 2008, 2:30pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/7 "2008-05-21T14:30:02Z")

</div>

[QUOTE=Jragon]

I’m more confused about things like 7\*7 in base 8, at least without cheating by sending it through base 10 and then converting.

[/QUOTE]

Remember that for doing decimal computations done by hand, we’ve memorized things like the decimal multiplication table to help us along. If you were going to make a habit of doing arithmetic in octal by hand, you’d presumably want to memorize the octal multiplication table, along with every possible sum of two octal digits.

The particular case of 7\*7 would be covered by exactly that — memorization or table look-up. For multi-digit multiplication (or anything else), you’d apply the same algorithm you learned in school for decimals, but of course you’d do all the primitive arithmetic in octal instead.

(On preview, **MikeS** said much the same thing.)

---

<div class="post-metadata">

**Author:** ![Frylock](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Frylock](https://boards.straightdope.com/u/Frylock)\
**Post date:** [May 21, 2008, 3:06pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/8 "2008-05-21T15:06:13Z")

</div>

[QUOTE=Indistinguishable]  
To the best of my knowledge, it has not yet been proven that every finite bit string appears in the binary expansion of pi. People often assume pi, and all other irrational numbers, to be what is technically known as a [“normal number”](http://en.wikipedia.org/wiki/Normal_number) (one whose limiting frequency of containing any particular block of digits is the same as would be expected from a uniformly random distribution), but this has definitely not yet been proven for pi (or e or sqrt(2) or any other familiar number), not even for a single base. Certainly, there are irrational numbers which fail to contain every finite bitstring (for example, the number given in binary by 0.1010010001000010000010000001…, which never contains the bitstring “11”)  
[/QUOTE]

Even if Pi is a normal number, doesn’t that only mean it _almost certainly_ has every bitstring?

ETA: After re-reading the beginning of the article, I think maybe not. Maybe a normal number really does have to have every bitstring in it somewhere.

-FrL-

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [May 21, 2008, 6:47pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/9 "2008-05-21T18:47:23Z")

</div>

Yes, a normal number has to have every particular bitstring in it somewhere, for if it lacked bitstring S (of length n), then the limiting frequency within it of S would be 0, as opposed to the 1/2^n expected from a uniformly random distribution.

I should be clear that it’s possible to contain every finite bitstring without being normal (for example, construct a normal number number in base 3, and then turn all the instances of the digit 2 into the digit 1), but that (to the best of my knowledge) π has not been proved to contain every bitstring by any means (it certainly hasn’t been proved to contain every digit-string in base-10), and the main reason people believe π contains every bitstring is simply because, a fortiori, they believe it to be normal.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [May 21, 2008, 6:58pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/10 "2008-05-21T18:58:56Z")

</div>

I think one can prove that almost all numbers are normal, correct? That is to say, that the set of non-normal numbers is of measure zero? If so, that would be a pretty good reason to suspect that pi (or any other number not known to be non-normal) is normal.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [May 21, 2008, 7:13pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/11 "2008-05-21T19:13:17Z")

</div>

Yes, “almost all” numbers are normal in precisely the sense you mention. (Going back to **Frylock** ’s mention of “almost certainly” (i.e., with probability 1, though not necessarily guaranteed), it’s not hard to show that a number drawn at uniform random from a finite real interval (e.g., [0, 1]) almost certainly will be normal, which suffices to establish that “almost all” real numbers are normal.)

But, for all that, very few mathematical constants have been proved to be normal (those which have been are generally “contrived” in some way, their definitions being very much in the flavor of constructing them as particular digit-sequences, rather than specifying them via arithmetic properties, so to speak). I’m not sure how valid it is to move from “Almost all reals are normal” to “Any real not known to be non-normal is very likely normal”; formalizing the use of the language of probability involved here is not straightforward, but it seems we have to acknowledge this: π was not selected at random out of the reals, it was brought to our attention because of certain arithmetic properties, and it may well be the case that such properties are not independent of normality.

For example, it has been conjectured on seemingly reasonable grounds that every irrational algebraic number is non-normal. So, despite the fact that sqrt(2) is not known to be non-normal, it does not seem as though we could consider ourselves to have pretty good reason to suspect that sqrt(2) is normal (though, of course, many people also conjecture that it _is_ normal).

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [May 21, 2008, 7:20pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/12 "2008-05-21T19:20:59Z")

</div>

[The “also” in that last parenthetical means “There are also (in addition to, but separate from, those who make the first conjecture) many people who conjecture that it _is_ normal”, not “There are many people who also (in addition to making the first conjecture) conjecture that it _is_ normal”.]

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [May 21, 2008, 8:14pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/13 "2008-05-21T20:14:21Z")

</div>

> [@](#):
>
> …but it seems we have to acknowledge this: π was not selected at random out of the reals, it was brought to our attention because of certain arithmetic properties, and it may well be the case that such properties are not independent of normality.

Oh, certainly. We don’t by any stretch know that pi is normal, and we can’t even say something like “we have strong reason to suspect…”. But the fact that most numbers are normal is, at least, a pretty good reason to suspect, as I said. Of course, that’s a weak enough standard of certainty that one can simultaneously suspect mutually-contradictory possibilities.

---

<div class="post-metadata">

**Author:** ![Exapno\_Mapcase](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/exapno_mapcase/32/1051_2.png) [@Exapno\_Mapcase](https://boards.straightdope.com/u/Exapno_Mapcase)\
**Post date:** [May 21, 2008, 8:15pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/14 "2008-05-21T20:15:01Z")

</div>

[QUOTE=Chronos]  
I think one can prove that almost all numbers are normal, correct? That is to say, that the set of non-normal numbers is of measure zero? If so, that would be a pretty good reason to suspect that pi (or any other number not known to be non-normal) is normal.  
[/QUOTE]

Non-normal numbers are infinite, since all rationals are non-normal. Yet since irrationals have a higher cardinality, the probability of striking a rational number by a random poke at the number line is zero.

None of this says anything about pi, specifically, though.

Ready for another go-round on infinite math? 😃

---

<div class="post-metadata">

**Author:** ![Frylock](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Frylock](https://boards.straightdope.com/u/Frylock)\
**Post date:** [May 21, 2008, 8:45pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/15 "2008-05-21T20:45:49Z")

</div>

[QUOTE=Exapno Mapcase]  
Non-normal numbers are infinite, since all rationals are non-normal. Yet since irrationals have a higher cardinality, the probability of striking a rational number by a random poke at the number line is zero.  
[/quote]

Since not all normal numbers are rational, it’s not clear what your point is.

-FrL-

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [May 21, 2008, 8:48pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/16 "2008-05-21T20:48:16Z")

</div>

It’s not clear to me what **Exapno Mapcase** is driving at either, but he did explicitly note that _no_ normal numbers are rational. I think perhaps he misunderstood **Chronos** ’s reference to the non-normal numbers having “measure zero”, and thought this somehow conflicted with the fact that there are infinitely many rationals.

---

<div class="post-metadata">

**Author:** ![Frylock](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Frylock](https://boards.straightdope.com/u/Frylock)\
**Post date:** [May 21, 2008, 8:50pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/17 "2008-05-21T20:50:17Z")

</div>

[QUOTE=Indistinguishable]

For example, it has been conjectured on seemingly reasonable grounds that every irrational algebraic number is non-normal.  
[/QUOTE]

On the off chance that it would be at all comprehensible to me, I’d be interested in finding out what those (seemingly) reasonable grounds were.

-FrL-

BTW I’m still reading your PM(s).

---

<div class="post-metadata">

**Author:** ![Frylock](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Frylock](https://boards.straightdope.com/u/Frylock)\
**Post date:** [May 21, 2008, 8:54pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/18 "2008-05-21T20:54:04Z")

</div>

[QUOTE=Indistinguishable]  
but he did explicitly note that _no_ normal numbers are rational.  
[/QUOTE]

Right you are. Sorry I missed that.

-FrL-

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [May 21, 2008, 9:05pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/19 "2008-05-21T21:05:27Z")

</div>

[QUOTE=Exapno Mapcase]  
Yet since irrationals have a higher cardinality, the probability of striking a rational number by a random poke at the number line is zero.  
[/QUOTE]

Speaking of another go-round on infinite math…

To show that the probability of obtaining a rational number (from the unit interval with a uniform random distribution, let’s say) is zero, which is the same as showing the rational numbers have measure zero, it is not enough to simply note that the rationals have smaller cardinality than the irrationals. This would be enough were one to assume [Martin’s Axiom](http://en.wikipedia.org/wiki/Martin%27s_axiom) (which is implied by the [continuum hypothesis](http://en.wikipedia.org/wiki/Continuum_hypothesis)), but without such non-standard assumptions, it is consistent for the unit interval to be splittable into two sets, one of lower cardinality than the other, without the smaller set having probability 0. In demonstrating that the rationals have measure zero, one actually appeals specifically to the fact that they are _countable_, which does suffice to establish the claim, on the grounds that measure is countably additive and singletons have measure zero; at higher cardinalities, however, this argument would fail, as measure is not required to be additive over higher-cardinalities (for example, the unit interval as a whole has measure 1, despite it being the union of an uncountable number of singletons of measure 0).

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [May 21, 2008, 9:14pm UTC](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072/20 "2008-05-21T21:14:01Z")

</div>

[QUOTE=Frylock]  
On the off chance that it would be at all comprehensible to me, I’d be interested in finding out what those (seemingly) reasonable grounds were.  
[/QUOTE]

Whoops, I had gotten reversed the conjecture I was thinking of. The conjecture was that every irrational algebraic number was normal; quite some egg on my face. There goes my example…

Still, no irrational algebraic number has ever been demonstrated to be normal in so much as a single base, which perhaps can blunt my embarrassment somewhat…

[Next page](https://boards.straightdope.com/t/how-do-you-do-non-whole-numbers-in-bases-other-than-10/450072.md?page=2)
