分配1个字节? [英] Allocation of 1 byte?

查看:83
本文介绍了分配1个字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,


我理解(可能是错的)最小的一块内存是

称为一个单词。如果这是正确的,那意味着如果我使用的是32位

OS,则一个字是4个字节。这就是为什么int的大小是4个字节的原因。

是一个字符然后得到1个字节。难道它也不能获得4个字节甚至

虽然它可能只能存储256个值吗?操作系统是否在进行一些修改?


谢谢

Sam

解决方案

2003年7月28日04:28:14 -0700, sa **** @ avenir.net (Samuel Thomas)写道:

你好朋友,

我理解(可能是错的)最小的一块内存是
叫一个字。


编号内存中最小的块称为字节,至少在C中。

如果这是正确的,这意味着如果我使用32位操作系统,则一个字是4个字节。


只要一个字节长8位,是的,或多或少。

这就是为什么int的大小是4字节的原因。


不是真的。 (或多或少)。

如何获得一个字符,然后获得1个字节。


因为char与字节相同,而字节是

可寻址存储的最小单位。

难道它也不可能获得4个字节
虽然它可能只能存储256个值吗?


它可能,也可能不是。这取决于实现平台,这可能需要一个字节超过8位。

操作系统是否正在进行某种修剪?


很少,如果有的话,操作系统会参与解释或执行

问题程序机器语言指令。

谢谢
Sam




-

Lew Pitcher

IT顾问,企业技术解决方案

多伦多道明银行金融集团


(表达的意见是我自己的,而不是我的雇主')




" Samuel Thomas" < SA **** @ avenir.net>在消息中写道

新闻:1a ************************** @ posting.google.c om ...

Hello Friends,

我理解(可能是错的)最小的一块内存被称为单词。如果这是正确的,那意味着如果我使用的是32位操作系统,则一个字是4个字节。这就是为什么int的大小是4个字节的原因。怎么然后一个char得到1个字节。难道它也不可能获得4个字节
虽然它可能只能存储256个值吗?操作系统是否正在进行一些修剪?

谢谢
Sam




从标准6.2.5开始:


声明为char类型的对象足以存储基本

执行字符集的任何成员。如果基本执行字符集的成员存储在

char对象中,则其值保证为正。如果任何其他字符存储在

char对象中,则结果值是实现定义的,但应在可以在该类型中表示的值的范围内。


char的大小取决于执行字符集的大小。你的系统。参考

术语,定义和符号。 (3.6),执行字符集的大小。被定义为1

字节。


-

杰夫


< blockquote>

" Jeff" <无**** @ notexist.com>在消息中写道

news:bg ********* @ imsp212.netvigator.com ...


Samuel Thomas < SA **** @ avenir.net>在消息中写道
新闻:1a ************************** @ posting.google.c om ...

Hello Friends,

我理解(可能是错的)最小的一块内存被称为单词。如果这是正确的,那意味着如果我使用的是32位操作系统,则一个字是4个字节。这就是为什么int的大小是4个字节的原因。怎么然后一个char得到1个字节。难道它也不可能获得4个字节
虽然它可能只能存储256个值吗?操作系统是否正在进行一些修剪?

谢谢
Sam
来自标准6.2.5:

一个对象声明为type char足以存储



基本执行字符集的任何成员。如果基本执行字符集
的成员存储在char对象中,则其值保证为正。如果任何其他
字符存储在char对象中,则结果值是实现定义的,但在可以用该类型表示的值范围内应为


char的大小取决于执行字符集的大小。您的
系统。参考术语,定义和符号。 (3.6),执行字符
设置的大小被定义为1个字节。

-
杰夫




你的观点是...... 。



Hello Friends,

I understand(could be wrong) that the smallest chunk of memory is
called a word. If that is correct, that means if I am using a 32 bit
OS a word is 4 bytes. So that''s why the size of an int is 4 bytes. How
is it that a char then gets 1 byte. Shouldn''t it also get 4 bytes even
though it might be able to store only 256 values? Is the OS doing some
sort of trimming?

Thanks
Sam

解决方案

On 28 Jul 2003 04:28:14 -0700, sa****@avenir.net (Samuel Thomas) wrote:

Hello Friends,

I understand(could be wrong) that the smallest chunk of memory is
called a word.
No. The smallest ''chunk'' of memory is called a ''byte'', at least in C.
If that is correct, that means if I am using a 32 bit
OS a word is 4 bytes.
So long as a byte is 8 bits long, yes, more or less.
So that''s why the size of an int is 4 bytes.
Not really. (more or less).
How
is it that a char then gets 1 byte.
Because a char is the same thing as a byte, and a byte is the smallest unit of
addressable storage.
Shouldn''t it also get 4 bytes even
though it might be able to store only 256 values?
It may, or it may not. This depends on the implementation platform, which may
require that a byte be longer than 8 bits.
Is the OS doing some sort of trimming?
Rarely, if ever, does the OS get involved in the interpretation or execution of
problem-program machine-language instructions.
Thanks
Sam



--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers'')



"Samuel Thomas" <sa****@avenir.net> wrote in message
news:1a**************************@posting.google.c om...

Hello Friends,

I understand(could be wrong) that the smallest chunk of memory is
called a word. If that is correct, that means if I am using a 32 bit
OS a word is 4 bytes. So that''s why the size of an int is 4 bytes. How
is it that a char then gets 1 byte. Shouldn''t it also get 4 bytes even
though it might be able to store only 256 values? Is the OS doing some
sort of trimming?

Thanks
Sam



From the standard 6.2.5 :

An object declared as type char is large enough to store any member of the basic
execution character set. If a member of the basic execution character set is stored in a
char object, its value is guaranteed to be positive. If any other character is stored in a
char object, the resulting value is implementation-defined but shall be within the range
of values that can be represented in that type.

The size of char depends on the size of "execution character set" of your system. Referring to the
"Terms, definitions, and symbols" (3.6), the size of "execution character set" is defined as 1
byte.

--
Jeff



"Jeff" <no****@notexist.com> wrote in message
news:bg*********@imsp212.netvigator.com...


"Samuel Thomas" <sa****@avenir.net> wrote in message
news:1a**************************@posting.google.c om...

Hello Friends,

I understand(could be wrong) that the smallest chunk of memory is
called a word. If that is correct, that means if I am using a 32 bit
OS a word is 4 bytes. So that''s why the size of an int is 4 bytes. How
is it that a char then gets 1 byte. Shouldn''t it also get 4 bytes even
though it might be able to store only 256 values? Is the OS doing some
sort of trimming?

Thanks
Sam
From the standard 6.2.5 :

An object declared as type char is large enough to store any member of the


basic execution character set. If a member of the basic execution character set is stored in a char object, its value is guaranteed to be positive. If any other character is stored in a char object, the resulting value is implementation-defined but shall be within the range of values that can be represented in that type.

The size of char depends on the size of "execution character set" of your system. Referring to the "Terms, definitions, and symbols" (3.6), the size of "execution character set" is defined as 1 byte.

--
Jeff



And your point is......



这篇关于分配1个字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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