Skip to content

edsonsoaresramos/asciiToBinary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

asciiToBinary

asciiToBinary - V: 1.0.0 This is a simple Python program that allows coding an ascii to binary number (in the alphabet). This simple program was developed to serve more as language study material and ascii coding rules to binary. The rules used here for encoding ASCII to a binary number were as follows:

  1. Iterate through the multiples of 2 to an 8-bit binary number group for each letter;
  2. Assign the value of the ascii code of the current letter to be encoded to a base variable (baseNumber);
  3. Compare the baseNunber with the first multiple of 2 for an 8-bit binary number group;
  4. If the current multiple of 2 is smaller and / or equal to the baseNumber, the binary bit will be 1;
  5. If the current multiple of 2 is smaller and / or equal to the baseNumber, subtract the baseNumber from the current multiple of 2 and assign it to the baseNumber variable;
  6. If the current multiple of 2 is greater than the baseNumber, the binary bit will be 0;
  7. If the current multiple of 2 is greater than the baseNumber, this will remain with the value of the letter ascii code;
  8. Continue the iteration by comparing if the multiple of 2 current is equal and / or smaller than the baseNumber.

Este é um programa simples de Python que permite codificar um ascii para binário (no alfabeto). Este simples programa foi desenvolvido para servir mais como material de estudo da linguagem e as regras de codificação de ascii para binario. As regras utilizadas aqui para a codificação de ASCII para um número binário foram as seguintes:

  1. Percorrer os múltiplos de 2 para um grupo de número binário de 8 bits para cada letra;
  2. Atribuir valor do código ascii da letra corrente a ser codificada à uma variável base (baseNumber);
  3. Comparar o baseNunber com o primeiro múltiplo de 2 para um grupo de número binário de 8 bits;
  4. Se o múltiplo de 2 corrente for menor e/ou igual ao baseNumber, o bit binário será 1;
  5. Se o múltiplo de 2 corrente for menor e/ou igual ao baseNumber, subtrair o baseNumber do múltiplo de 2 corrente e atribuir à variável baseNumber;
  6. Se o múltiplo de 2 corrente for maior ao baseNumber, o bit binário será 0;
  7. Se o múltiplo de 2 corrente for maior ao baseNumber, este permanecerá com o valor do código ascii da letra;
  8. Continuar a iteração comparando se o múltiplo de 2 corrente for igual e/ou menor ao baseNumber.

Releases

No releases published

Packages

No packages published

Languages