16位整型和32位整型和64位整型 [英] 16 bit Int vs 32 bit Int vs 64 bit Int

查看:1398
本文介绍了16位整型和32位整型和64位整型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在想这个很长一段时间,因为我从来没有对计算机科学(我在高中),所以请原谅我的无知关于这个问题的。正规教育

在支持三种​​类型的标题列出整数的平台,一个人的好,为什么? (我知道,每一种为int的长度不同的内存,但我不知道这意味着什么或它如何影响性能,或者从开发人员的角度来看,其中一个比对方更有优势)。

感谢您在您的帮助。

解决方案

更好是一种主观的术语,但有些整数是在某些平台上更好的性能。

例如,在32位计算机的CPU被优化在一个时间来处理一个32位的值,32(由术语如32位平台和Win32引用)是指比特的数CPU可以消耗或产生在一个周期内。 (这是一个非常简单的解释,但它跨越得到的总体思路)。

在64位计算机(最新的AMD和Intel处理器属于这一类),在CPU进行了优化,可处理64位值的时间。

因此​​,在一个32位的平台,一个16位整数装入一个32位地址就需要有16位置零,使得CPU可以在其上进行操作;一个32位的整数。将立即可用而没有任何改变,并在64位整数将需要在两个或更多个CPU周期上操作(一次用于低32位,然后再次为高32位)

相反,在64位的平台上,16位整数需要有48位0,高32位整数需要有32位0,高和64位整数可以立即操作上。

每个平台和CPU具有天然位岬(如32或64),而这通常限制了一些可以通过该CPU可以访问的其他资源(例如,32的3GB / 4GB存储器限制比特处理器)。 80386处理器系列(以及后来的x86)处理器取得了32位的常态,但现在像AMD和英特尔则公司目前正在制作64位的常态。

I've been wondering this for a long time since I've never had "formal" education on computer science (I'm in highschool), so please excuse my ignorance on the subject.

On a platform that supports the three types of integers listed in the title, which one's better and why? (I know that every kind of int has a different length in memory, but I'm not sure what that means or how it affects performance or, from a developer's view point, which one has more advantages over the other).

Thank you in advance for your help.

解决方案

"Better" is a subjective term, but some integers are more performant on certain platforms.

For example, in a 32-bit computer (referenced by terms like 32-bit platform and Win32) the CPU is optimized to handle a 32-bit value at a time, and the 32 refers to the number of bits that the CPU can consume or produce in a single cycle. (This is a really simplistic explanation, but it gets the general idea across).

In a 64-bit computer (most recent AMD and Intel processors fall into this category), the CPU is optimized to handle 64-bit values at a time.

So, on a 32-bit platform, a 16-bit integer loaded into a 32-bit address would need to have 16 bits zeroed out so that the CPU could operate on it; a 32-bit integer would be immediately usable without any alteration, and a 64-bit integer would need to be operated on in two or more CPU cycles (once for the low 32-bits, and then again for the high 32-bits).

Conversely, on a 64-bit platform, 16-bit integers would need to have 48 bits zeroed, 32-bit integers would need to have 32 bits zeroed, and 64-bit integers could be operated on immediately.

Each platform and CPU has a 'native' bit-ness (like 32 or 64), and this usually limits some of the other resources that can be accessed by that CPU (for example, the 3GB/4GB memory limitation of 32-bit processors). The 80386 processor family (and later x86) processors made 32-bit the norm, but now companies like AMD and then Intel are currently making 64-bit the norm.

这篇关于16位整型和32位整型和64位整型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆