Reference:
https://golang.org/ref/spec#Size_and_alignment_guarantees
Numeric types:
A numeric type represents sets of integer or floating-point values.
https://golang.org/ref/spec#Size_and_alignment_guarantees
Numeric types:
A numeric type represents sets of integer or floating-point values.
The predeclared architecture-independent numeric types are:
- uint8 the set of all unsigned 8-bit integers (0 to 255)
- uint16 the set of all unsigned 16-bit integers (0 to 65535)
- uint32 the set of all unsigned 32-bit integers (0 to 4294967295)
- uint64 the set of all unsigned 64-bit integers (0 to 18446744073709551615)
- int8 the set of all signed 8-bit integers (-128 to 127)
- int16 the set of all signed 16-bit integers (-32768 to 32767)
- int32 the set of all signed 32-bit integers (-2147483648 to 2147483647)
- int64 the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807)
- float32 the set of all IEEE-754 32-bit floating-point numbers
- float64 the set of all IEEE-754 64-bit floating-point numbers
- complex64 the set of all complex numbers with float32 real and imaginary parts
- complex128 the set of all complex numbers with float64 real and imaginary parts
- byte alias for uint8
- rune alias for int32
For the numeric types, the following sizes are guaranteed:
type size in bytes
byte, uint8, int8 1
uint16, int16 2
uint32, int32, float32 4
uint64, int64, float64, complex64 8
complex128 16
The following minimal alignment properties are guaranteed:
- For a variable x of any type: unsafe.Alignof(x) is at least 1.
- For a variable x of struct type: unsafe.Alignof(x) is the largest of all the values unsafe.Alignof(x.f) for each field f of x, but at least 1.
- For a variable x of array type: unsafe.Alignof(x) is the same as the alignment of a variable of the array's element type.
- A struct or array type has size zero if it contains no fields (or elements, respectively) that have a size greater than zero. Two distinct zero-size variables may have the same address in memory.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.