Golang datatypes: Difference between revisions
From wikinotes
Line 22: | Line 22: | ||
signed | signed | ||
<syntaxhighlight lang="go"> | <syntaxhighlight lang="go"> | ||
int // (however many bits your CPU word-size is) | |||
int8 // 128 - 127 | int8 // 128 - 127 | ||
int16 // 32,768 - 32,767 | int16 // 32,768 - 32,767 | ||
Line 30: | Line 31: | ||
unsigned | unsigned | ||
<syntaxhighlight lang="go"> | <syntaxhighlight lang="go"> | ||
unit // (however many bits your CPU word-size is) | |||
uint8 // 0 - 255 | uint8 // 0 - 255 | ||
uint16 // 0 - 65,535 | uint16 // 0 - 65,535 |
Revision as of 14:34, 29 May 2022
Literal Types
"foo" // string 123 // int (cpu-arch dependent bitsize) 3.14 // float64 6.2e25 // float64
Text
Numeric
Integers
Integer sizes are expressed by their bit-size.
signed
int // (however many bits your CPU word-size is) int8 // 128 - 127 int16 // 32,768 - 32,767 int32 // 2,147,483,648 - 2,147,483,647 int64 // 9,223,372,036,854,775,808 - 9,223,372,036,854,775,807unsigned
unit // (however many bits your CPU word-size is) uint8 // 0 - 255 uint16 // 0 - 65,535 uint32 // 0 - 4,294,967,295 // uint64 does not existBytes
Same as
uint8
.math/big
Slow, but handles numbers of any size.