This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ieee754_to_decimal(ieee754): | |
| #Convertimos el decimal a binario de 32 bits | |
| ieee754_binary_string_padded = format(int(ieee754, 16), '0>32b') | |
| #Extraemos el signo | |
| signo = ieee754_binary_string_padded[0] | |
| es_negativo = signo == "1" | |
| #Extraemos el exponente | |
| exponente = ieee754_binary_string_padded[1:9] | |
| #Extraemos la mantisa | |
| mantisa = ieee754_binary_string_padded[9:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def decimal_to_ieee754(decimal): | |
| # Separar la parte entera y fraccionaria | |
| entero = abs(int(decimal)) | |
| fraccion = abs(decimal) - entero | |
| # Convertir la parte entera a binario | |
| binario_entero = '' | |
| binario_fraccion = '' | |
| exponente = 0 | |
| signo = 0 | |
| mantisa = '' |