Answer the question
In order to leave comments, you need to log in
How do you convert numbers from binary to decimal?
I wonder who translates how. Maybe you know the most convenient / fastest way to translate?
Answer the question
In order to leave comments, you need to log in
If the number is small, then it is enough just to remember the weights of the digits - 1, 2, 4, .... The average programmer, I think, remembers the powers of two at least up to 65536.
And sum up the weights of those digits in which there is a unit.
let's say you need to translate 10101. you write down the powers of two in a row , you
16 8 4 2 1
put a mask in accordance with the binary number
16 0 4 0 1
, you add it up, you get 21,
there is absolutely no point in raising anything to some degree and fencing other matan. the binary system is not in vain chosen as the main one for processors :)
1101 going from the end
1 * 2^0
+
0 * 2^1
+
1 * 2^2
+
1 * 2^3
= 13
proof m.wolframalpha.com/input/?i=bin+1101+to+decimal&x=0&y =0
Convenient and fast - a standard calculator.
Or is it required in the mind?
I somehow read one convenient way on Habré, but apparently I forgot it already ...
It sounds like this:
let's say we have 101010, the
first three digits (or digits, as it is more correct) is 5, you can just remember
this 0 - this is just a multiplication by two, total 10
1 - multiply by 2 and add one, total 21
0 - multiply by 2, total epic 42.
It seems everything is fine here, but when I wrote a larger random number (it was 91), I could not translate it correctly already ...
Maybe does anyone know about this method?
In the mind, if a short number, according to the principle 010101 - where there is a unit, this means that there is a two in a degree equal to the ordinal number of the digit from right to left (counting from zero).
Thus it will turn out: 0 + _ + 2 ^ 4 + _ + 2 ^ 2 _ + 2 ^ 0
Then I add. 0+16+0+4+0+1=21.
Perhaps my method is a little bit through J. The easiest way is to use a calculator :)
There are several ways ... now in the 6th grade I teach according to Bosova's textbook and two methods are described there:
1. As the sum of the terms of the series (1,2,4,8,16 ...)
2. By dividing by 2 and writing the remainder of the division .
Children are comfortable in the second way to translate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question