Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math: show values of MaxXxx and MinXxx on documentation #51282

Closed
shuLhan opened this issue Feb 20, 2022 · 1 comment
Closed

math: show values of MaxXxx and MinXxx on documentation #51282

shuLhan opened this issue Feb 20, 2022 · 1 comment
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@shuLhan
Copy link
Contributor

shuLhan commented Feb 20, 2022

Currently, the math package show the constants values for all except for max and min integer values (MaxIntXxx, MaxUintXxx, MinIntXxx,and MinUintXxx).

Usually developer get each values of max and min integers manually (by writing some script), or view it through /ref/spec [1], or search in internet.

The idea is to allow developer to check and/or copy their values through godoc.

What did you expect to see?

const (
    MaxInt    = 1<<(intSize-1) - 1  // Equal to MaxInt32 on 32-bit or MaxInt64 on 64-bit.
    MinInt    = -1 << (intSize - 1) // Equal to MinInt32 on 32-bit or MinInt64 on 64-bit.
    MaxInt8   = 1<<7 - 1            // 127
    MinInt8   = -1 << 7             // -128
    MaxInt16  = 1<<15 - 1           // 32767
    MinInt16  = -1 << 15            // -32768
    MaxInt32  = 1<<31 - 1           // 2147483647
    MinInt32  = -1 << 31            // -2147483648
    MaxInt64  = 1<<63 - 1           // 9223372036854775807
    MinInt64  = -1 << 63            // -9223372036854775808
    MaxUint   = 1<<intSize - 1      // Equal to MaxUint32 on 32-bit or MaxUint64 on 64-bit.
    MaxUint8  = 1<<8 - 1            // 255
    MaxUint16 = 1<<16 - 1           // 65535
    MaxUint32 = 1<<32 - 1           // 4294967295
    MaxUint64 = 1<<64 - 1           // 18446744073709551615
)

What did you see instead?

const (
	MaxInt    = 1<<(intSize-1) - 1
	MinInt    = -1 << (intSize - 1)
	MaxInt8   = 1<<7 - 1
	MinInt8   = -1 << 7
	MaxInt16  = 1<<15 - 1
	MinInt16  = -1 << 15
	MaxInt32  = 1<<31 - 1
	MinInt32  = -1 << 31
	MaxInt64  = 1<<63 - 1
	MinInt64  = -1 << 63
	MaxUint   = 1<<intSize - 1
	MaxUint8  = 1<<8 - 1
	MaxUint16 = 1<<16 - 1
	MaxUint32 = 1<<32 - 1
	MaxUint64 = 1<<64 - 1
)

[1] https://golang.org/ref/spec#Numeric_types

@gopherbot
Copy link

Change https://go.dev/cl/343990 mentions this issue: math: show the value of each max and min integer constants in comments

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 20, 2022
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
@golang golang locked and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants