Cover page by David Chisnall

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

3. Numbers

When I first learned C, the compiler supported 16-bit ints and 32-bit longs. A few years later, it became more common for int to be 32 bits. A lot of code was written with assumptions about the sizes of C types, and this caused people a lot of problems when 64-bit systems became common.

The C99 standard introduced the stdint.h header, which defined types like uint32_t, an unsigned integer that was 32 bits on any platform. This helped a bit, but on some platforms a cast between a uint32_t and an unsigned int was safe and wouldn’t generate a warning, since they were the same underlying type, while on others it was not.

Go learned from this mess and provides explicitly sized integer and floating-point types from the start. A uint64 is ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required