Probably simple decimal/binary conversion

  • Thread starter mikeg542
  • Start date
In summary, 20248462 is not a valid 24 bit binary number and needs to be converted to 1001101001111011110001110.
  • #1
mikeg542
2
0

Homework Statement


This is a question on a homework assignment, and of course I'm not expecting a direct answer but just a way to figure out how to get what I need to know.

The question is: Take you 8-digit student number (20248462 in this example) and convert this to a 24 bit equivalent binary number string. Make the proper adjustments to make your results 24 bit.

Homework Equations


The Attempt at a Solution


First I just tried a direct changing of the student number to binary and got 111101110010110001110111101110010110001110, which is quite a bit larger than 24 bits. Then I tried treating each number as a hex value, but obviously 8*4 = 32bits. I then thought to do it as scientific notation like a floating point value, but again, we only can do that as 32 bits.

So how do I go about doing this? I'm sure it's something easy and I'm just being stupid.
 
Last edited:
Physics news on Phys.org
  • #2
mikeg542 said:

Homework Statement


This is a question on a homework assignment, and of course I'm not expecting a direct answer but just a way to figure out how to get what I need to know.

The question is: Take you 8-digit student number (20248462 in this example) and convert this number to a 24 bit equivalent binary number string. Make the proper adjustments to make your results 24 bit.


Homework Equations





The Attempt at a Solution


First I just tried a direct changing of the student number to binary and got 111101110010110001110111101110010110001110
How did you get this number? It's way larger than it should be.The binary representation of 20248462 will fit in 25 bits. I don't know what trick you need to use to squeeze it into 24 bits.
mikeg542 said:
, which is quite a bit larger than 24 bits. Then I tried treating each number as a hex value, but obviously 8*4 = 32bits. I then thought to do it as scientific notation like a floating point value, but again, we only can do that as 32 bits.

So how do I go about doing this? I'm sure it's something easy and I'm just being stupid.
 
  • #3
The largest number that may be represented with an (unsigned) 24 bit binary integer is 2^24 - 1 = 16777215

20248462 > 16777215

But you didn't do the conversion right anyway.
 
  • #4
Yeah, I figured that out (having got it as 25 bits earlier). I copied the wrong number from the work I've been doing. It's actually 1001101001111011110001110, but yeah, I looked through all the course material and there is nothing on turning 20248462 into a 24bit binary number.
 
  • #5


It seems like you are on the right track with your attempts so far. As you mentioned, converting each digit to binary and putting them together would result in a number that is larger than 24 bits. This is because you are using 8 bits for each digit (1 byte), which is the standard for representing numbers in binary.

To get a 24 bit equivalent, you can use a process called "padding". This means adding extra 0s to the beginning of the binary string until you reach the desired number of bits. In this case, you would need to add 16 0s to the beginning of your binary string to make it 24 bits long.

Alternatively, you can also use a process called "truncation". This means cutting off the extra bits at the end of your binary string until you reach the desired number of bits. In this case, you would need to remove the first 8 bits of your binary string to make it 24 bits long.

Both methods will result in a 24 bit equivalent binary number string. You can choose whichever method is more intuitive for you. I hope this helps!
 

FAQ: Probably simple decimal/binary conversion

1. What is the difference between decimal and binary numbers?

Decimal numbers are based on the base 10 system, where each digit can have 10 possible values (0-9). Binary numbers, on the other hand, are based on the base 2 system, where each digit can only have 2 possible values (0 or 1).

2. How do I convert a decimal number to binary?

To convert a decimal number to binary, you can use the repeated division by 2 method. Start by dividing the decimal number by 2 and noting the remainder. Then, divide the quotient by 2 and note the remainder again. Repeat this process until the quotient becomes 0. The binary number is formed by writing the remainders in reverse order.

3. How do I convert a binary number to decimal?

To convert a binary number to decimal, you can use the positional notation method. Start by writing the binary number with the rightmost digit being in the "ones" place, and the leftmost digit being in the "eights" place. Then, multiply each digit by its corresponding power of 2 and add all the resulting values together to get the decimal equivalent.

4. Can I convert a decimal number with a fractional part to binary?

Yes, you can convert a decimal number with a fractional part to binary by using the repeated multiplication method. Start by multiplying the fractional part by 2 and noting the whole number part. Then, multiply the decimal part of the product by 2 and repeat this process until the decimal part becomes 0. The binary number is formed by writing the whole number parts in order.

5. Why is binary used in computer systems?

Binary is used in computer systems because it is a simple and efficient way to represent data using only 0s and 1s. Since computers use electronic circuits that can only be in two states (on or off), the binary system is a natural fit for storing and processing data in computer systems.

Similar threads

Back
Top