Golang datatypes: Difference between revisions
From wikinotes
(Created page with "= Implied Types = <blockquote> </blockquote><!-- Implied Types --> = Text = <blockquote> </blockquote><!-- Text --> = Numeric = <blockquote> </blockquote><!-- Numeric -->...") |
|||
Line 11: | Line 11: | ||
= Numeric = | = Numeric = | ||
<blockquote> | <blockquote> | ||
== Integers == | |||
<blockquote> | |||
Integer sizes are expressed by their bit-size. | |||
signed | |||
<syntaxhighlight lang="go"> | |||
int8 // 128 - 127 | |||
int16 // 32,768 - 32,767 | |||
int32 // 2,147,483,648 - 2,147,483,647 | |||
int64 // 9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 | |||
</syntaxhighlight> | |||
unsigned | |||
<syntaxhighlight lang="go"> | |||
uint8 // 0 - 255 | |||
uint16 // 0 - 65,535 | |||
uint32 // 0 - 4,294,967,295 | |||
// uint64 does not exist | |||
</syntaxhighlight> | |||
</blockquote><!-- Integers --> | |||
= Bytes = | |||
<blockquote> | |||
Same as <code>uint8</code>. | |||
</blockquote><!-- Bytes --> | |||
= math/big = | |||
<blockquote> | |||
Slow, but handles numbers of any size. | |||
</blockquote><!-- math/big --> | |||
</blockquote><!-- Numeric --> | </blockquote><!-- Numeric --> | ||
Revision as of 13:53, 29 May 2022
Implied Types
Text
Numeric
Integers
Integer sizes are expressed by their bit-size.
signed
int8 // 128 - 127 int16 // 32,768 - 32,767 int32 // 2,147,483,648 - 2,147,483,647 int64 // 9,223,372,036,854,775,808 - 9,223,372,036,854,775,807unsigned
uint8 // 0 - 255 uint16 // 0 - 65,535 uint32 // 0 - 4,294,967,295 // uint64 does not existBytes
Same as
uint8
.math/big
Slow, but handles numbers of any size.