From af9ae75d5c6e9622ceb6484ca389a843799f996a Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 9 Feb 2024 01:00:54 -0500 Subject: [PATCH] Add doc comments to integer --- integer/integer.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/integer/integer.go b/integer/integer.go index ba49eda..76d24d8 100644 --- a/integer/integer.go +++ b/integer/integer.go @@ -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) }