Add doc comments to integer

This commit is contained in:
Sasha Koshka 2024-02-09 01:00:54 -05:00
parent 100861dc47
commit af9ae75d5c
1 changed files with 13 additions and 4 deletions

View File

@ -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)
}