Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Familiarízate con el Código Binario | Sistema Binario de Numeración
Sistemas Numerales 101

book
Familiarízate con el Código Binario

Supongo que te habrás enterado de que los ordenadores ven su código de forma diferente a ti: esta brillante máquina puede leer código binario, que consta de 0 y 1. El código binario es parecido a este 00011100, pero los ceros en las posiciones de reenvío son opcionales, así que puedes quitarlos y escribir el código como 11100. Es fácil para un ordenador, pero un reto para los humanos; por eso, vas a familiarizarte con su descifrado:

Regla

Aquí debes hacer las mismas operaciones que en el capítulo anterior. Busca el índice de un número (sigue empezando por la derecha) y luego multiplica el número actual por 2 elevado a la potencia del índice. Por ejemplo 101->1x2^2 + 0x2^1 + 1x2^0 = 4 + 0 + 1 = 5.

Uso del sistema binario

La principal razón para utilizar el código binario es que un ordenador está formado por miles de millones de transistores que responden a señales binarias 0 o 1; por lo tanto, las "palabras informáticas" que sólo incluyen 0 y 1 envían señales a los transistores, 1 significa encendido, y 0 significa apagado.

# Defining binary number
binary_number = 1010111
#creating a variable for storing the converted decimal number
decimal_number = 0
# The text should be realised here due to the reason that further the binary number will be changed
print("The number in binary numeral system is:", binary_number)
# Variable for storing the power
power = 0
# The loop executes till the number is zero
while binary_number != 0:
# The remainder of division by 10 allows us to receive the last digit of a number
last_digit = binary_number % 10
# Multiplying digit by 2 raised to the relevant power
result = last_digit * pow(2, power)
# Adding the result to the current decimal number receive the decimal one
decimal_number = decimal_number + result
# Decreasing decimal number using integer division by 10, allows getting rid of the last digit
binary_number = binary_number // 10
# Increasing power by 1
power = power + 1
# Printing the result
print("The number in decimal numeral system is:", decimal_number)
12345678910111213141516171819202122
# Defining binary number binary_number = 1010111 #creating a variable for storing the converted decimal number decimal_number = 0 # The text should be realised here due to the reason that further the binary number will be changed print("The number in binary numeral system is:", binary_number) # Variable for storing the power power = 0 # The loop executes till the number is zero while binary_number != 0: # The remainder of division by 10 allows us to receive the last digit of a number last_digit = binary_number % 10 # Multiplying digit by 2 raised to the relevant power result = last_digit * pow(2, power) # Adding the result to the current decimal number receive the decimal one decimal_number = decimal_number + result # Decreasing decimal number using integer division by 10, allows getting rid of the last digit binary_number = binary_number // 10 # Increasing power by 1 power = power + 1 # Printing the result print("The number in decimal numeral system is:", decimal_number)
copy
Tarea

Swipe to start coding

¡Es hora de perfeccionar tus habilidades! Convierte un número del sistema numérico binario al decimal e imprime el resultado. Debes seguir el algoritmo de la derecha y rellenar los huecos. Como resultado, obtendrás uno de los números mágicos. Pero la explicación te espera al final del capítulo.

  1. 2. Define la variable poder y asígnale 0.
    1. Cuenta el resto de la división número_binario entre 10.
    1. Multiplicar último_dígito por el 2 elevado a la potencia correspondiente.
    1. Sumar el resultado a un número decimal.
  2. Aumentar potencia en 1.
  3. Imprime el número_decimal.

Solución

binary_number = 11011000001
decimal_number = 0
print("The number in binary numeral system is:", binary_number)
power = 0
while binary_number != 0:
last_digit = binary_number % 10
result = last_digit * pow(2, power)
decimal_number = decimal_number + result
binary_number = binary_number // 10
power = power + 1
print("The number in decimal numeral system is:", decimal_number)

Nota

¿Supongo que has recibido 1729 y quieres saber por qué he afirmado que este número es mágico? Todo está completamente claro: se llama número Hardy-Ramanujan por una anécdota del matemático británico G.H Hardly. Si le parece apasionante esta información, puede leer sobre la anécdota en "El hombre que conocía el infinito", de Robert Knaigel. Es el número más pequeño que se puede expresar como la suma de dos cubos diferentes de dos maneras distintas. 1729 se puede calcular como la suma de los cubos de 10 y 9, un cubo de 10 es 1000 también el cubo de 9 es 729, y la suma de los cubos de 12 y 1.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 2
binary_number = 11011000001
decimal_number = 0
# Output the binary number
___("The number in binary numeral system is: ", binary_number)
# Define the variable power and assign 0 to it
___ = ___
while binary_number != 0:
#count the remainder of division binary_number by 10
last_digit = binary_number ___ 10
# Multiply last_digit by the 2 raised to the relevant power
result = last_digit ___ # Two outcames is posiible
# Add the result to a decimal number
___ = ___ + result
binary_number = binary_number // 10
# Increase power by 1
___
# Output the decimal_number
___("The number in decimal numeral system is:", decimal_number)

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt