From the course: Go for Developers: Practical Techniques for Effective Coding

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Numbers

Numbers

- Go has many numeric types. Integers come in both unsigned and signed types. A signed integer can store positive and negative numbers. An unsigned integer can only store positive numbers. Both types come in 8, 16, 32, and 64 bit types. Floats come in either 32 or 64 bit types. Go also offers two complex numeric types, complex64 and complex128. Finally, Go offers two implementation-specific integer types, int and uint. On 32-bit machines, these types are 32 bit. On 64-bit machines, these types are 64 bits. In Go, picking the correct type usually has more to do with performance for the target architecture you're programming for than the size of the data you're working with. However, without needing to know the specific ramifications of performance for your program, you can follow some of these basic guidelines when first starting out. For integer data, it is common to use the implementation types likes int and uint. This will typically result in the fastest processing speed for your…

Contents