answersLogoWhite

0


Best Answer

The short answer is 1111110.

For my long answer, the following code example is a complete program that will take an integer as input and print out the corresponding binary value. Because I've coded it around being able to view all the bits of an int, small numbers will have quite a few leading 0s.

Code example:#include #include #define iBYTE_BITS 8 #define iINT_BITS (sizeof(int) * iBYTE_BITS) void vIntToBinary(int iNum, char *cpString); int main(int iArgc, char *acpArgv[]) { char acBinaryString[iINT_BITS + 1]; int iInputNum; if(iArgc != 2) { fprintf(stderr, "Please provide an integer argument.\n"); } else { iInputNum = atoi(acpArgv[1]); vIntToBinary(iInputNum, acBinaryString); printf("%d: %s\n", iInputNum, acBinaryString); } return 0; } void vIntToBinary(int iNum, char *cpString) { char cBit; for(cBit = iINT_BITS - 1; cBit >= 0; cBit--, cpString++) { *cpString = ((iNum >> cBit) & 1) + '0'; } *cpString = '\0'; }
User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you convert decimal numbers like 126 to binary?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Number 15 in binary form?

Rather than tell you what the answer is, I think it better that you learn how to do this your self. By asking the question you must realize that each binary digit can have a value of one or zero. Just like with decimal numbers, the digit of lest value is on the right and has a decimal value of one. The digit immediately to its left has a value that is twice that of it neighbor to the right and also half the value of its neighbor to the left.Here is the decimal values of 8 binary digits.[128][64][32][16][8][4][2][1] decimal value( 8)( 7)( 6)( 5)(4)(3)(2)(1) digit placeLets convert 25 decimal into binary.The largest decimal value that can be subtracted is 16 with 3 digits to the left, write down 3 zeros as place holders for the 3 left digits. Follow by a one.000125 - 16 = 9The next binary digit to the right has a decimal value of 8 and can be subtracted from 9 so we write down another 1.000119 - 8 = 1Now for each binary digit that has a decimal value greater than the remainder write a zero.0001100Now there is just the 1 left to deal with. Any time there is only 1 left you can just write down a 1.00011001So with that short intro to converting decimal into binary you should be dangerous enough to do your own decimal to binary conversions. (If still in doubt try, Google for an explanation that makes more sense to you).


Conversion of binary to octal?

Binary is a base 2 number system, while octal is base 8. This happens to make conversion between binary and octal fairly trivial, although more complex than conversion to hexadecimal. To convert to octal from binary, take each three bits, starting from the least significant bit, and convert them to their octal equivalent. Examples: 25510 = 111111112 = 11 111 111 = 3778 17410 = 101011102 = 10 101 110 = 2568 You can repeat this process for as many bits as you need. A 24-bit number should translate into 8 octal numbers, for reference.


What is 00001010.01100100.00000111.00010101 to decimal?

It's quite easy to convert binary into hexadecimal (hex) by grouping each 4 binary digits (bits) into a single binary hex digit: 0A 64 07 15 From there it's easier to convert into decimal in the head: 10 100 7 21 If you will be doing much in the way of programming computers, or working with TCP/IP networking, it is definitely a good idea to spend some time familiarising yourself with hexadecimal and converting between hex, binary and decimal. For reference, converting from binary to hex is done like this: 0000 = 0 0001 = 1 0010 = 2 0011 = 3 0100 = 4 0101 = 5 0110 = 6 0111 = 7 1000 = 8 1001 = 9 1010 = A 1011 = B 1100 = C 1101 = D 1110 = E 1111 = F


What is the difference between decimal and binary odometer?

ticking over and getting a new no. like do the clock or some type of speedometer...


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.

Related questions

How do you add and subtract the binary number system?

You do it exactly like decimal subtraction, and when needed you borrow from the next higher place digit, however remember you borrow 2 everytime and not 10. Some people convert the two binary numbers into decimal, do the subtraction and then convert the result back to binary. Following is an example of binary subtraction. 1001 0110 ____ 0011 ____ I started explaining the borrowing process in words but it gets confusing. Please relate it to the borrowing process in decimal.


Write a c program to convert binary number to decimal number?

How is this a question? Sounds like you should do more of your homework offline.


How are binary numbers read?

Binary numbers follow a place-value rule just like ordinary decimal numbers. The difference is that instead of each digit indicating a power of 10 ("base 10"), binary numbers use powers of 2 ("base 2"). Also, because the digits used can't go any higher than one less than the base, 0 and 1 are the only digits in a binary number just like 0 ... 9 (=10-1) are the only digits in a base 10 number.To convert a binary number to an ordinary base-10 number, start reading from the right. Multiply each digit by the power of two corresponding to that position, starting with the zero power. For example, if you had the binary number 100011 you would convert it like this. Remember, conversion starts from the right side so the digits are read and multiplied in the order 1-1-0-0-0-11 x 20 + 1 x 21 + 0 x 22 + 0 x 23 + 0 x 24 + 1 x 25 which translates to1x1 + 1x2 + 0x4 + 0x8 + 0x16 + 1x32So, 100011 in binary is the same as 35 in ordinary decimal numbers.


How do you convert the second decimal number to make like decimals?

Decimal numbers are always "like", because they all have the same type of denominator: a power of 10. Just add 0s so that both numbers have the same number of digits after the decimal point. Or, just write the two numbers so that the decimal points line up, one below the other.


Are there periods in decimal numbers?

There are decimal points in decimal numbers. They look just like periods.


What is the answer1101110 divide0101?

10902.0792


What is the binary digit of 31?

The number 31 (decimal) can be represented as a binary number this way: 11111 ...which is 1 + 2 + 4 + 8 + 16 = 31 Note the number 31 is one less than a power of two. Numbers like that are always strings of 1's for binary digits.


How do you convert 14 into binary?

00010100 Like: 1 = 0001 4 = 0100


What is the binary number for the decimal number 134?

The binary number for the decimal 134 is calculated as 128+4+2=10000110. The binary number system is used internally on almost all computers and computer based devices like cell phones.


Examples of what pi looks like?

In binary: 11.00100100001111110110 In decimal: 3.14159265358979323846 In hexadecimal: 3.243F6A8885A308D31319


Floating point representation in binary why is it important to represent and how the decimal is placed in the binary?

It's a tricky area: Decimal numbers can be represented exactly. In contrast, numbers like 1.1 do not have an exact representation in binary floating point. End users typically would not expect 1.1 to display as 1.1000000000000001 as it does with binary floating point. The exactness carries over into arithmetic. In decimal floating point, 0.1 + 0.1 + 0.1 - 0.3 is exactly equal to zero. In binary floating point, the result is 5.5511151231257827e-017. While near to zero, the differences prevent reliable equality testing and differences can accumulate. For this reason, decimal is preferred in accounting applications which have strict equality invariants. So you have to be carefull how you store floating point decimals in binary. It can also be used in a fraction. It must be simplufied then reduced and multiplied.


How is the decimal of an irrational number different from the decimal of a rational number?

The difference is that rational numbers stay with the same numbers. Like the decimal 1.247247247247... While an irrational number is continuous but does not keep the same numbers. Like the decimal 1.123456789...