Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:21:23+00:00 2026-05-24T03:21:23+00:00

How does one specify the maximum value representable for an unsigned integer type? I

  • 0

How does one specify the maximum value representable for an unsigned integer type?

I would like to know how to initialize min in the loop below that iteratively computes min and max lengths from some structs.

var minLen uint = ???
var maxLen uint = 0
for _, thing := range sliceOfThings {
  if minLen > thing.n { minLen = thing.n }
  if maxLen < thing.n { maxLen = thing.n }
}
if minLen > maxLen {
  // If there are no values, clamp min at 0 so that min <= max.
  minLen = 0
}

so that the first time through the comparison, minLen >= n.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:21:24+00:00Added an answer on May 24, 2026 at 3:21 am

    https://groups.google.com/group/golang-nuts/msg/71c307e4d73024ce?pli=1

    The germane part:

    Since integer types use two’s complement arithmetic, you can infer the
    min/max constant values for int and uint. For example,

    const MaxUint = ^uint(0) 
    const MinUint = 0 
    const MaxInt = int(MaxUint >> 1) 
    const MinInt = -MaxInt - 1
    

    As per @CarelZA’s comment:

    uint8  : 0 to 255 
    uint16 : 0 to 65535 
    uint32 : 0 to 4294967295 
    uint64 : 0 to 18446744073709551615 
    int8   : -128 to 127 
    int16  : -32768 to 32767 
    int32  : -2147483648 to 2147483647 
    int64  : -9223372036854775808 to 9223372036854775807
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to specify a security level for my custom binding
I'm at a bit of a loss here. I have a one-to-many relationship between
How can I define an array of string in c then iterate with a
Facebook Requests Dialog seem to generate two kinds of notification messages Janet sent you
I use CSS transitions pretty frequently now but find it limiting to only have
So, I went to create an EDMX file today, and while going through the
i want to validate email addresses to make sure they are college edu addresses.
I've been reading the Swing tutorial How to Use Tables , and although it
I have a Dojo-DataGrid which is programatically populated as below : var jsonStore =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.