answersLogoWhite

0

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

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

RossRoss
Every question is just a happy little opportunity.
Chat with Ross
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga

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.