1

We are learning about converting Binary to Decimal (and vice-versa) as well as other base-conversion methods, but I don't understand the necessity of this knowledge.

Are there any real-world uses for converting numbers between different bases?

drudge
  • 35,471
  • 7
  • 34
  • 45
samim
  • 41
  • 1
  • 2

3 Answers3

1
  • When dealing with Unicode escape codes— '\u2014' in Javascript is — in HTML

  • When debugging— many debuggers show all numbers in hex

  • When writing bitmasks— it's more convenient to specify powers of two in hex (or by writing 1 << 4)

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

In this article I describe a concrete use case. In short, suppose you have a series of bytes you want to transfer using some transport mechanism, but you cannot simply pass the payload as bytes, because you are not able to send binary content. Let's say you can only use 64 characters for encoding the payload. A solution to this problem is to convert the bytes (8-bit characters) into 6-bit characters. Here the number conversion comes into play. Consider the series of bytes as a big number whose base is 256. Then convert it into a number with base 64 and you are done. Each digit of the new base 64 number now denotes a character of your encoded payload...

Jonny Dee
  • 837
  • 4
  • 12
0

If you have a device, such as a hard drive, that can only have a set number of states, you can only count in a number system with that many states.

Because a computer's byte only have on and off, you can only represent 0 and 1. Therefore a base2 system is used.

If you have a device that had 3 states, you could represent 0, 1 and 2, and therefore count in a base 3 system.

Tyler Carter
  • 60,743
  • 20
  • 130
  • 150