【发布时间】:2017-08-31 02:01:35
【问题描述】:
对于不同的操作系统平台会不会有所不同。假设变量占用的内存字节数在 Windows/Linux 中会有所不同。
【问题讨论】:
对于不同的操作系统平台会不会有所不同。假设变量占用的内存字节数在 Windows/Linux 中会有所不同。
【问题讨论】:
非正式地当有人问以下任何问题时?
What is the size required to store a variable?
或
What is the memory required to store a variable?
被问到的实际问题是:
What is the size of the memory required to define the variable?
一个变量不过是内存,而变量标识符是用来标识的,我们说的具体字节是什么?
是的,bytes 中的变量大小对于不同的操作系统/架构是不同的。这就是我们拥有cross-platform 数据类型的原因。
例如:在C 中,我们有整数数据类型,如int16_t、int32_t,它们将分别占用16 bits 和32 bits 内存,而int 可以占用不同数量的@ 987654332@ 在不同的机器上。
【讨论】: