Options

how to convert decimal 3 200 000 to binary ?

txn41655txn41655 Member Posts: 53 ■■□□□□□□□□
Hi

could anyone tell me how to convert decimal 3 200 000 to binary ? I can convert smaller decimal number to binary using the binary positions like 128 64 32 8 4 1 2 ...... but how could I convert decimal 3 200 000 to binary without writing the long binary position until that number? is there a way to calculate it? Thanks.....

Comments

  • Options
    dontstopdontstop Member Posts: 579 ■■■■□□□□□□
    I'm not sure there really is a trick/shortcut to this. When you have a number that large you're going to need all of the intermediary binary positions for accuracy anyway. This is precisely the reason why humans don't count in binary ;)

    Why are you trying to convert such a large number?
  • Options
    clarsonclarson Member Posts: 903 ■■■■□□□□□□
    use a calculator like a mathematician does

    but the number has to be small enough to be stored in the calculator's memory. for a 128 bit processor that is a pretty big number. On an 8 bit processor not so big.
  • Options
    OctalDumpOctalDump Member Posts: 1,722
    Well, one short cut is that you know it is even, so the left most digit will be zero :)

    The other thing is by eyeballing it, it'd be close to 1 1000 0000 0000 0000 0000. This is because 1 million is close to 2^20 (it's a bit more than million). So it depends if that's enough precision.

    On a multi-choice test without a calculator, those two things would probably eliminate at least 1 answer, if not more.
    2017 Goals - Something Cisco, Something Linux, Agile PM
  • Options
    txn41655txn41655 Member Posts: 53 ■■□□□□□□□□
    I need to subnet ip 16.0.0.0 (need between 50-60 hosts and at least 2500 subnets).
    So I borrowed 18bits which give 262144 possible subnets and 62 host per subnet, therfore my mask is 255.255.255.192/26.
    I know the 1st is : 16.0.0.64
    2nd is : 16.0.0.128
    3rd i : 16.0.0.192
    *I multiply the subnet by 64. example 3rd = 3 x 64 = 192 (16.0.0.192)
    But what if i need to provide the 50 000th or 150 000th network ? 50 000 x 64 = 3 200 000 cannot work!? Thanks.
  • Options
    rob42rob42 Member Posts: 423
    txn41655 wrote: »
    ...
    I know the 1st is : 16.0.0.64
    2nd is : 16.0.0.128
    3rd i : 16.0.0.192

    The 2nd N/work is .64, not the 1st. The 1st N/work is .0
    *I multiply the subnet by 64. example 3rd = 3 x 64 = 192 (16.0.0.192)
    But what if i need to provide the 50 000th or 150 000th network ? 50 000 x 64 = 3 200 000 cannot work!? Thanks.

    You have to think in terms of base 256, not base 10.

    With base 10

    0|8 + 1 = 0|9
    0|9 + 1 = 1|0

    and so on

    With base 256...

    0|254 + 1 = 0|255
    0|255 + 1 = 1|0

    and so on.

    It turns out that if you count your networks in multiples of 4, starting with a ID of zero, as it's easier to see...

    ID 0 = 16.0.0.0
    ID 4 = 16.0.1.0
    ID 8 = 16.0.2.0
    ID 12 = 16.0.3.0
    ID 16 = 16.0.4.0
    ...

    ID 1024 = 16.1.0.0
    ID 2048 = 16.2.0.0
    ID 3072 = 16.3.0.0
    ID 4096 = 16.4.0.0

    and so on...

    I'll let you take it from here.
    No longer an active member
  • Options
    clarsonclarson Member Posts: 903 ■■■■□□□□□□
    what you need to do is think of each octet as a separate digit.
    in the 4th octet you have 4 possible values: 0, 64, 128, 192
    so for each value in the 3rd octet, you have 4 values in the 4th octet.
    0.0.0.x is 4 subnets
    0.0.1.x is 4 more subnets
    0.0.2.x is 4 more subnets
    and so on
    the 3rd octet has 256 possible values, 0-255, and for each of those the 4th octet has 4 possible values
    so with just the 3rd and 4th octets you have 256x4=1024 subnets
    16.0.0.0 - 16.0.255.192 1024 subnets

    so if you wanted 50,000 subnets. divide 50,000 by 1024 which is less than 49 so the 2nd octet need to be 49th network
    for 0011 0000 and you'd have over 50,000 subnets between 16.0.0.0 - 16.48.255.192
    and to be precise it would be 49 x 1024 = 50, 176

    to know the 50 000 network you need to remove the 176 divide by 4 = 44 255-44 = 211
    so 16.48.211.192/26 is the 50,000th network

    similar for 150 000. divide by 1024 is less than 147 so the 2nd octet is 146 (less one because zero is counted)
    1001 0010 and you'd have over 150 000 subnets between 16.0.0.0 - 16.146.255.192 actually 150 528
    528/4 = 132 255-132 = 123 so 16.146.123.192/26 is the 150 000th network
  • Options
    txn41655txn41655 Member Posts: 53 ■■□□□□□□□□
    thanks clarson! now I understand and can calculate correctly with subnets. thanks octalDump, rob42!
Sign In or Register to comment.