answersLogoWhite

0

First of all we will talk about how binary number are converted back into decimal representation and later we will have program.

Here is the formula of this transformation:

Binary number: a3a2a1a0

Decimal number a x 23 + a x 22 + a x 21 + a x 20

Example:

Binary: 1101

Decimal: 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 8 + 4 + 0 + 1 = 13

And here we have our program:

#include

#include

#include

int main() {

char str[100];

int ind;

int sum = 0;

printf("Please enter binary number: ");

scanf("%s", str);

for(ind = 0; ind < strlen(str); ind++) {

sum += (str[ind] - 0x30) * pow(2, strlen(str) - ind - 1);

}

printf("Number in decimal would be %d\n", sum);

return 0;

}

Testing:

Please enter binary number: 1101

Number in decimal would be 13

Please enter binary number: 10000001

Number in decimal would be 129

Please enter binary number: 11111111

Number in decimal would be 255

Please enter binary number: 0

Number in decimal would be 0

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

BCD to Gray Code Converter?

BCD refers to Binary Code Decimal there are no diagrams it is just a numbers system GRAY code is a means to make one reliable state to change at a time eliminating false coding because of transitions in counters and such


How do you make a digital object counter?

A: First you need a object detector that give out a pulse per each. That becomes the clock for any the input to a counter that will count up in binary coded decimal and of these there are many to choose from. Eventually it will fill up and starts over unless there is a reset along the time of counting. that is the basic.


Explain binary coded decimal?

Binary Coded Decimal (BCD) is a set of coding systems for storing decimal digits in binary code. There are several such codes, I will give examples of 3: straight BCD, XS3 BCD, and 2 of 5 BCD. Straight BCD uses the actual binary value of the decimal digit value: 0 = 0000 1 = 0001 2 = 0010 3 = 0011 4 = 0100 5 = 0101 6 = 0110 7 = 0111 8 = 1000 9 = 1001 XS3 BCD adds 3 to the binary value of the decimal digit value to make the code: 0 = 0011 1 = 0100 2 = 0101 3 = 0110 4 = 0111 5 = 1000 6 = 1001 7 = 1010 8 = 1011 9 = 1100 2 of 5 BCD uses a 5 bit code where only 2 bits can be on in a decimal digit's code: 0 = 00011 1 = 11000 2 = 10100 3 = 10010 4 = 10001 5 = 01100 6 = 01010 7 = 01001 8 = 00110 9 = 00101


What is the significance of hexadecimal What is the significance of binary Who are they used by?

Binary (base-2) and hexadecimal (base-16) are commonly used by programmers. Binary computers only understand binary encodings. That is, all information (both instructions and data) must be converted into a numeric value; digital information. Humans like to use decimal notation whenever possible, but in order to program a computer in its own native language we must convert all values to binary, the only language the computer actually understands. However, binary is difficult to work with because there are only two symbols: 0 and 1. Decimal, on the other hand, has ten symbols, 0 to 9, so we can easily notate all values from 0 to 9 using just one digit. In binary we would need at least 4 digits to notate the same range of numbers. Thus binary numbers tend to be much longer than their decimal equivalents and are difficult for humans to comprehend; a single digit in the wrong place is much harder to spot. Although we can program the computer to convert decimal notation to native binary, this has a runtime cost because there is no direct conversion between decimal and binary notation. But base-2 is directly related to all bases that are themselves a power of 2. Thus quaternary (base-4), octal (base-8) and hexadecimal (base-16) are all directly related to binary and are therefore more easily converted back and forth than is decimal. We use hexadecimal because it has relatively few symbols (16), and each hex digit maps 1:1 with a group of 4 bits. Since 4 bits is half a byte we call hexadecimal digits nybbles. Since two nybbles make a byte, we can represent any group of 8 bits with just two symbols instead of 8 binary digits. Octal is also used because it allows us to map bits in groups of 3, which can be useful in systems that use a 9-bit byte rather than the more common 8-bit byte, but is also useful when we need to work in base-8 itself.


What are two advantages of using binary numbers rather than decimal numbers in a computer system?

Your question is actually flawed...binary system is not used in digital systems... Rather, systems using binary numbers only are called digital systems... It is common knowledge that, digital electronics employs just 2 states (or rather numbers, as mathematicians put it...) the two numbers being '0' and '1'. Obviously, it is easier to design electronic systems dealing with just 2 states...It's majorly this ease, that led to such exponential development in the field of digital electronics. It ios also cheaper to make or produce such systems...

Related Questions

What is the binary number of 209.85.153.94?

Just use the Windows calculator, and set it to scientific mode, or use any scientific calculator that supports binary/decimal. In the Windows calculator, make sure you are in decimal, type in each of the four numbers, then select "Binary" to convert to binary. You will have to fill out some of the binary numbers with zeroes to the left (each one must have 8 binary digits).Just use the Windows calculator, and set it to scientific mode, or use any scientific calculator that supports binary/decimal. In the Windows calculator, make sure you are in decimal, type in each of the four numbers, then select "Binary" to convert to binary. You will have to fill out some of the binary numbers with zeroes to the left (each one must have 8 binary digits).Just use the Windows calculator, and set it to scientific mode, or use any scientific calculator that supports binary/decimal. In the Windows calculator, make sure you are in decimal, type in each of the four numbers, then select "Binary" to convert to binary. You will have to fill out some of the binary numbers with zeroes to the left (each one must have 8 binary digits).Just use the Windows calculator, and set it to scientific mode, or use any scientific calculator that supports binary/decimal. In the Windows calculator, make sure you are in decimal, type in each of the four numbers, then select "Binary" to convert to binary. You will have to fill out some of the binary numbers with zeroes to the left (each one must have 8 binary digits).


What are some basic binary questions for beginners?

How many people does it take to make a binary couple ?... 10


Can you make money in binary options trading?

You can make only if you understan basic forex first. binary options based on mostly currencies, you have to know forex techniques by logic or by nature law. then you can make money with binary options.


What is the computer equivalent 00110111 in decimal?

This is probably a binary number. To convert binary to decimal, assuming you have Windows:Open the Windows Calculator (press Windows-R, then type "calc").Make sure it is in scientific mode (menu command: View - Scientific).Click in "Bin" to change to binary mode.Type in your binary number.Clicking on "Dec" will go back to decimal mode (and convert the number you typed to decimal).Note that the Windows calculator only handles this type of calculations for integers.


What is the main function of binary?

to make it easier for computers to calculate. just as your fingers, you need 10 fingers to count to 10 in decimal, while in binary, you only need 2 basic status, left or right, forward or backward, false or true, which is more efficient. another reason is the diode which composed the computer has only two basic status, on or off, corresponding to 1 and 0.


What does the decimal number 255 mean in binary?

Oh, dude, you're asking about binary now? Alright, so in binary, the decimal number 255 is represented as 11111111. It's like all those ones are just hanging out together, having a binary party. So yeah, 255 in binary is just a bunch of ones chilling together.


What are the two numbers the binary system uses?

In theory any two symbols would do, but usually they are 1 and 0.So, for example, the binary for three is 11, and for thirteen the binary is 1101.To make conversions, use the calculator that comes with a Windows operating system. Set the View to Scientific, make sure the Dec (for decimal) button is selected, and key in a number. Then selected the Bin (binary) button, and the binary equivalent displays.


What are the advantages and disadvantages of binary code decimal?

Advantage of binary over decimal: information can be recorded and stored in any dichotomous variable: magnetised or not magnetised (most electronic media), pit or no pit (optoelectronic media CDs/DVDs). For decimal it would be necessary to store as 10 different levels of magnetisation or depths of pits. Not so easy to make such a system error-free. Advantage of decimal over binary: fewer "digits" required. Every ten binary digits (1024 values) can be replaced by just a shade more than three decimal digits (1000 values). So the number of digits to be stored is less than a third.


BCD to Gray Code Converter?

BCD refers to Binary Code Decimal there are no diagrams it is just a numbers system GRAY code is a means to make one reliable state to change at a time eliminating false coding because of transitions in counters and such


How many black holes make one binary system?

well you wouldn't need any to make a black holes to make binary systems but what do make binary systems are two stars.


How do you make a digital object counter?

A: First you need a object detector that give out a pulse per each. That becomes the clock for any the input to a counter that will count up in binary coded decimal and of these there are many to choose from. Eventually it will fill up and starts over unless there is a reset along the time of counting. that is the basic.


How do you make 101010 into 950 using one line?

You can make 101010 into 950 by interpreting it as a binary number. The binary number 101010 equals 42 in decimal. To achieve 950, you can add an operation, such as multiplying by 22.62 (approximately), but if strictly using one line, you could simply express a mathematical relationship, such as ( 101010 - 100060 = 950 ).