0
$\begingroup$

This may be a silly question, but if a computer works in binary how can you encript numbers using decimal?

$\endgroup$
  • 1
    $\begingroup$ The Wikipedia article on IEEE 754 already explains this in great detail, and there doesn't seem to be any point in somebody writing out another version of the same thing. Is there something specific that you don't understand? $\endgroup$ – David Richerby Jan 24 at 19:34
1
$\begingroup$

Fair question. First of all, it's worth noting that the IEEE decimal formats are fairly modern and not used particularly often—they're meant for the rare use cases where things need to round in a specific way, mostly in finances.

But, there are various ways to encode a truly decimal number (i.e. a number stored as a series of base-10 digits) in binary. The simplest is called BCD (Binary Coded Decimal), which uses four bits to represent each digit. Many early computers used this system because humans are used to decimal and found it more intuitive.

BCD is kind of wasteful, because four bits can represent any number from 0 to 15, and a single digit only need to represent a number from 0 to 9. So IEEE uses slightly different packings, called Binary Integer Decimal and Densely Packed Decimal. They're somewhat more complicated, but the idea is the same: you have a one-to-one mapping between decimal digits and binary bits, wasting as few bits as possible.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.