Read Origin
技术博主
- 多看开发者大会!
- ThePrimeTime
- CodeAesthetic
- Molly Rocket
What’s so special about 2147483648?
by Sandra Henry-Stocker, Unix Dweeb, from NetWorkWorld 945870
tags: Data Center, Linux, Open Source
难度:EASY
First of all, it’s a power of 2. That’s undoubtedly not the most obvious thing unless you’re some kind of mathematical genius. And, to be exact, it’s 2^31. That’s significant — as you’ll see in a minute.
In binary, 2147483647 is 01111111111111111111111111111111 and it’s the biggest positive number that will fit in 32 bits when using the “two’s complement” notation (补码) — the way of representing numbers that allows for negative values. If we could use that leftmost (high order) bit, the largest possible number would be twice as large since every extra bit doubles the range of numbers that a binary number can represent.
And 2147483648 just happens to be the number you’d get if you multiplied 256 * 256 * 256 * 256 and then divided the result by 2. Not excited yet? Give me a moment.