Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any limitations when going from binary to decimal (just as when going from decimal to binary)?

As we all know, not all decimal numbers can be represented in binary (with a finite number of digits).

I'm wondering, can all (finite) binary numbers be represented using (a finite number of) decimal digits? I suspect so, since all "primitives" in binary ("0.5", "0.125", etc) can be represented with a finite number of decimal digits.

So, my question is the following: What characterizes a "compatible base-change"? I.e., what are the mathematical properties that hold for "Base 2 → Base 10" but does not hold for "Base 10 → Base 2"?

(Put formally: What properties must N and M have, in order to ensure that all finite Base-N numbers have a corresponding finite Base-M number?)

like image 263
aioobe Avatar asked Jul 05 '11 12:07

aioobe


People also ask

What are the rules for converting decimal numbers to binary?

The simplest way to convert a decimal number to a binary number is by dividing the given number repeatedly by 2 until we get 0 as the quotient. Then, we write the remainders in the reverse order to get the binary value of the given decimal number.

Why is it sometimes advantageous to use binary numbers instead of decimal?

It is more difficult to convert from binary to decimal and from decimal to binary. The advantage of the binary system is its simplicity. A computing device can be created out of anything that has a series of switches, each of which can alternate between an “on” position and an “off” position.

Why do we need to convert binary to decimal?

Similarly, the decimal number system has a base of 10, as it has 10 digits to represent a number. The conversion of numbers from binary to decimal is important as it helps to read numbers that are represented as a set of 0s and 1s.

What is the relationship between binary and decimal?

Difference between the binary and decimal systemsThe number system that represents a number in terms of 0 to 9 digits is a decimal number system. A binary system has only two digits, i.e., 0 and 1. A decimal number system has ten digits, i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.


1 Answers

If n is a binary fraction, then n = a / 2k for integers a and k.

That means that n = (a · 5k) / (2k · 5k) = (a · 5k) / 10k

So every binary fraction is a decimal fraction.

In the general case, every fraction to base N is also a fraction to base M if and only if N divides Mk for some k (or, equivalently, if every prime factor of N is also a prime factor of M). An argument similar to the one I gave above for 2 and 10 handles the "if" direction. For the "only if" direction, here's a sketch proof for you to fill in: suppose that 1 / N = a / Mk, then Mk = a · N, therefore N divides Mk.

So binary can be converted to decimal without loss because 2 is factor of 10, but decimal cannot be converted to binary without loss, because 5 is a factor of 10 but not a factor of 2.

like image 169
Gareth Rees Avatar answered Oct 06 '22 08:10

Gareth Rees