Add doc comments to integer
This commit is contained in:
parent
100861dc47
commit
af9ae75d5c
@ -1,17 +1,26 @@
|
||||
// Package integer provides utilities for working with integer data.
|
||||
package integer
|
||||
|
||||
func UnsignedMin(width int) uint64 {
|
||||
// UnsignedMin returns the minimum value that an unsigned integer of the
|
||||
// specified width can represent.
|
||||
func UnsignedMin (width int) uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func UnsignedMax(width int) uint64 {
|
||||
// UnsignedMax returns the maximum value that an unsigned integer of the
|
||||
// specified width can represent.
|
||||
func UnsignedMax (width int) uint64 {
|
||||
return (1 << width) - 1
|
||||
}
|
||||
|
||||
func SignedMin(width int) int64 {
|
||||
// SignedMin returns the minimum value that a signed integer of the specified
|
||||
// width can represent.
|
||||
func SignedMin (width int) int64 {
|
||||
return -1 - int64(UnsignedMax(width) / 2)
|
||||
}
|
||||
|
||||
func SignedMax(width int) int64 {
|
||||
// SignedMax returns the maximum value that a signed integer of the specified
|
||||
// width can represent.
|
||||
func SignedMax (width int) int64 {
|
||||
return int64(UnsignedMax(width) / 2)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user