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

ParseInt/ParseFloat The bitSize int can you delete or ignore #35036

Closed
mkgti opened this issue Oct 21, 2019 · 1 comment
Closed

ParseInt/ParseFloat The bitSize int can you delete or ignore #35036

mkgti opened this issue Oct 21, 2019 · 1 comment

Comments

@mkgti
Copy link

mkgti commented Oct 21, 2019

// The bitSize argument specifies the integer type
// that the result must fit into. Bit sizes 0, 8, 16, 32, and 64
// correspond to int, int8, int16, int32, and int64.
// If bitSize is below 0 or above 64, an error is returned.

func ParseInt(s string, base int, bitSize int) (i int64, err error)

return i int64;
bitSize int if 8/16/32 to int64(int8/16/32) return.

@odeke-em
Copy link
Member

Hello there @mkgti, thank you for asking this question and welcome to the Go project!

We use an int64 as the return value, which is the maximum of those bit sizes so 0, 8, 16, 32 and 64 can all fit into 64 bits. As the docs guide, if you use 0 as the bitSize, it'll try to fit the bits into int whose value varies across whether you are on 32 bit or 64 bit architectures.

Anyways, we don't use the Go issue tracker to ask question. For asking questions, please see:

@golang golang locked and limited conversation to collaborators Oct 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants