ZeroDigitsCompress
DRAFT

Misconception:

A decimal number like 9000000000000000 has 16 decimal digits. Each of the 15 0 digits takes up only one bit. This makes it possible to store this number in a 32-bit int variable.

Incorrect

In integer numbers, decimal digits with value `0` take less storage than decimal digits with other values

Correct

Correction
Here is what's right.

Numbers are stored in binary two’s complement representation. An int uses 32 bits of storage, and, when using two’s complement notation, these 32 bits can represent numbers between -2^31 (-2147483648) … +2^31-1 (2147483647).

The numbers are not represented in BCD (binary-coded-decimal) representation, where each decimal digit would take up exactly 4 binary bits.

The numbers also are not encoded in some compressed form (e.g., that digits of value 0 would take less space than digits of other values.

Language

Java

Concepts

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.