<p>tbh, this raises confusing if you were programming in java or cpp</p>
<hr/>**评论:**<br/><br/>iroflmaowtf: <pre><p><a href="https://golang.org/pkg/builtin/#int" rel="nofollow">https://golang.org/pkg/builtin/#int</a></p>
<blockquote>
<p>int is a signed integer type that is <strong><em>at least 32 bits in size</em></strong>. It is a distinct type, however, and <strong><em>not an alias for, say, int32.</em></strong></p>
</blockquote></pre>: <pre><p>[deleted]</p></pre>TheMerovius: <pre><blockquote>
<p>int is 64 bits on 64-bit platforms, and 32 bits on 32-bit platforms.</p>
</blockquote>
<p>nit: int is either int32 or int64; an implementation can choose whatever it wants, no matter what platform it runs on (for example, GopherJS on my laptop runs on a 64 bit platform, but uses int32 for ints, as they have to fit in a float64).</p></pre>nsd433: <pre><p>As others have said, int and int32 are not the same, and that's why you have both. Most of the time you want a reasonable int. Other times you want an int which truncates at 32 bits.</p>
<p>You mention C++. C and C++ have the same destinction. In C/C++ 'int' is a reasonable integer size on the target CPU, and int32_t is a signed integer with exactly 32 bits.</p></pre>faiface: <pre><p>Surprised no one mentioned that int usually has 64 bits on 64-bit systems and 32 bits on 32-bit systems. The distinction from both int32 and int64 is clear.</p></pre>irene634: <pre><p>If that is correct, it is the same to use int and int64 on 64-bit systems? </p></pre>faiface: <pre><p>No. On 64-bit systems, both types allow same sets of values, but are different in the Go type system and values of one need to be explicitly converted to the other.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传