When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

AkshajK's blog

By AkshajK, history, 6 years ago, In English

Hey all,

I spent some time writing a textbook on how to efficiently convert between different bases, and thought it may be useful to those of you who are learning this for the first time.

Link: https://drive.google.com/file/d/12CeDNZO_trww-ZtGWMdSUCrhN8kcbi2U/view

  • Vote: I like it
  • +48
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it +70 Vote: I do not like it

I think a lot of time and effort could have been saved by simply presenting the general case (i.e. converting base x to base 10, then from base 10 to base y), with various examples. Nevertheless, I applaud the quality and quantity work you put into this document. Very thorough.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    i feel so silly, that indeed would have been much simpler! thanks for the suggestion.

»
6 years ago, # |
  Vote: I like it +127 Vote: I do not like it

This seems to claim the most efficient way to convert from base 2 to base 4 is as follows. First, convert from base 2 to base 10. Next, convert from base 10 to base 4. This is wrong, a more efficient way would be to group digits in pairs, and convert each pair in isolation.

Well, perhaps it indeed was the most efficient way to write a computer program which would then write the 800-page book.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it -15 Vote: I do not like it

    Finding primes, the programming approach: write a sieve.

    Finding primes, the engineering approach: 1 is not a prime, 2 is a prime, all higher even numbers aren't primes so let's ignore them, 3 is a prime, 5 is a prime, 7 is a prime, 9 is a prime, 11 is a prime, 13 is a prime, 15 is a prime, 17 is a prime, 19 is a prime...

»
6 years ago, # |
  Vote: I like it +134 Vote: I do not like it

I once needed to convert a hex number (base 16) to base 2. Looks like I need to buy a different book to accomplish this.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It's April 1, 2015 already? minimario

»
6 years ago, # |
Rev. 2   Vote: I like it +25 Vote: I do not like it

this book is rather shitty :(

»
6 years ago, # |
  Vote: I like it +29 Vote: I do not like it

Please get this published somewhere! I need this in printed form :)

By the way, when can we expect part 2, where we'll learn how to convert between bases up to 16?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +27 Vote: I do not like it

    part 2 should be out in around 10 years so for those of you curious about Hexadecimal, please stay tuned!

»
6 years ago, # |
  Vote: I like it +38 Vote: I do not like it

I think your book is missing cases of converting from base A to base B, where A = B. Regardless, a fine piece of effort!

»
6 years ago, # |
  Vote: I like it +31 Vote: I do not like it

I need help converting to/from base 1 and it's not covered in this book...

»
6 years ago, # |
  Vote: I like it +24 Vote: I do not like it

This stunning treatise seems to redefine the field of number theory.