整体类型 [英] integral types

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

问题描述

您好。


我想知道一些事情......

C ++是否仅适用于32位以上的机器?

我从long int类型必须至少32位的
这个事实推断出来。我是对还是不对? :|

是否可以在某些嵌入式平台上使用C ++,使用

16位或8位整数算术?如果是的话,怎么办呢?

32位整数是否必须通过实现来模拟?

或者可能通过删除''long int''类型? [但它仍然是

标准投诉呢?]


-

SasQ

Hello.

I''m wondering about something...
Is C++ designed for 32-bit-and-more machines only?
I''ve deduced it from the fact that a ''long int'' type has to be
at least 32-bit. Am I right or not? :|
Is it possible to use C++ for some embedded platforms using
16-bit or 8-bit integral arithmetics? If yes, how can it be done?
Would 32-bit integers have to be emulated by implementation?
Or maybe by dropping out the ''long int'' type? [but is it still
standard-complaint then?]

--
SasQ

推荐答案

* SasQ:
* SasQ:

>

我想知道什么。 ..

C ++仅适用于32位和更多机器吗?
>
I''m wondering about something...
Is C++ designed for 32-bit-and-more machines only?



No.

No.


我从'a'中推断出它'' 'long int''类型必须至少为b-b
。我是对还是不对? :|
I''ve deduced it from the fact that a ''long int'' type has to be
at least 32-bit. Am I right or not? :|



''long int''必须至少为32位。

''long int'' has to be at least 32 bits.


是否可以使用C ++为某些嵌入式平台使用

16位或8位整数算术?
Is it possible to use C++ for some embedded platforms using
16-bit or 8-bit integral arithmetics?



是。

Yes.


如果是,怎么办?
If yes, how can it be done?



为该平台使用编译器,或者也许是交叉编译器。

Using a compiler for that platform, or perhaps a cross-compiler.


是否必须通过实现来模拟32位整数?
Would 32-bit integers have to be emulated by implementation?



是的。

Yes.


或者可能通过删除''long int''类型? [但是它仍然是

标准投诉呢?]
Or maybe by dropping out the ''long int'' type? [but is it still
standard-complaint then?]



不,它不符合标准 - 放弃'' long int'',但是

C ++标准区分了托管和托管。和独立

实现,后者主要用于嵌入式工作,

允许丢弃(不提供)大部分标准库。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕东西?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?

No, it wouldn''t be standard-compliant by dropping ''long int'', but the
C++ standard differentiates between "hosted" and "free-standing"
implementations, the latter being meant primarily for embedded work,
allowed to drop (not offer) most of the standard library.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


SasQ写道:
SasQ wrote:

你好。


我想知道什么......

C ++是否仅适用于32位及更多机器?
Hello.

I''m wondering about something...
Is C++ designed for 32-bit-and-more machines only?



编号C ++仅用于参数化的非确定性抽象

机器(见[1.9 / 1])。有真正的机器的C ++编译器

是一个相当惊人的奇迹,无论它们的字长如何。

No. C++ is designed for use on parameterized nondeterministic abstract
machines only (see [1.9/1]). That there are C++ compilers for real machines
is a quite astonishing miracle regardless of their word length.


我''从long int类型必须至少为b-b
这一事实推断出它至少32位。我是对还是不对? :|
I''ve deduced it from the fact that a ''long int'' type has to be
at least 32-bit. Am I right or not? :|



你是对的,因为long int至少有32位。但我不明白这是什么意思。这意味着什么是C ++的设计目的。

You are right in that long int has at least 32 bits. But I don''t see how
this implies anything about what C++ is designed for.


是否有可能使用C ++为某些嵌入式平台使用

16位或8位整数算术?
Is it possible to use C++ for some embedded platforms using
16-bit or 8-bit integral arithmetics?



这是关于那些

平台的C ++编译器可用性的问题吗?如果是这样,我建议你调查一下你感兴趣的特定平台



Is that a question about the availability of C++ compilers for those
platforms? If so, I suggest you investigate the particular platform you are
interested in.


如果是的话,怎么样呢?做了什么?是否必须通过

实现来模拟32位整数?
If yes, how can it be done? Would 32-bit integers have to be emulated by
implementation?



是的,这将是要走的路。

Yes, that would be the way to go.


或者可能通过删除出''long int''类型? [但它仍然是

标准投诉呢?]
Or maybe by dropping out the ''long int'' type? [but is it still
standard-complaint then?]



这不符合标准。

现在,如果你发现编译器生成的代码处理32位
整数类型太大或太慢而且如果你愿意牺牲

long整数类型无论如何,那么你应该觉得可以接受的只是没有

使用长积分类型。

最好


Kai-Uwe Bux

That would not be standard compliant.
Now, if you find that the compiler generated code to deal with 32 bit
integer types is too bulky or slow and if you were willing to sacrifice the
long integral types anyway, then you should find it acceptable to just not
use the long integral types.
Best

Kai-Uwe Bux


* Kai-Uwe Bux:
* Kai-Uwe Bux:

SasQ写道:
SasQ wrote:

>您好。

我在想什么......
C ++是否仅适用于32位以上的机器?
>Hello.

I''m wondering about something...
Is C++ designed for 32-bit-and-more machines only?



编号C ++仅用于参数化的非确定性抽象

机器(见[1.9 / 1])。有真正的机器的C ++编译器

是一个非常惊人的奇迹,无论它们的字长。


No. C++ is designed for use on parameterized nondeterministic abstract
machines only (see [1.9/1]). That there are C++ compilers for real machines
is a quite astonishing miracle regardless of their word length.



如果用抽象的

机器定义C ++,那将是惊人的 - 因为那时看似抽象的定义

机器本身无处可寻(搜索标准为

维也纳或类似的东西不会产生任何结果,我认为。)


令人高兴的是,C ++不是用抽象的

机器定义的。


C ++标准定义执行C ++程序/作为/ b $ b抽象机器的效果,即抽象机器是C ++程序的效果,符合C ++程序的规则。按照定义的另一种方式来定义

。这尤其意味着

中关于任何构造效果的标准中的陈述不应该被解释为某个抽象机器中的效果(这将产生一个

无限递归和无能为力的定义);相反它是直接

构造的效果,并且/是/抽象机器。


和各种C ++构造的影响(从而,抽象的

机器,这是这类效果的总和)已经非常仔细地制作,以便在实际机器上对应并高效。


C ++和C是实用工程师的语言。


-

答:因为它弄乱了订单人们通常会阅读文字。

问:为什么这么糟糕?

A:热门帖子。

问:什么是usenet和电子邮件中最烦人的事情是什么?

That would be astonishing if C++ was defined in terms of the abstract
machine -- because then seemingly the definition of the abstract
machine itself would be nowhere to be found (searching the standard for
"Vienna" or something like that would not yield any results, I think).

Happily it''s not the case that C++ is defined in terms of an abstract
machine.

The C++ standard defines the effects of execution of a C++ program /as/
an abstract machine, i.e., the abstract machine is the effect of a C++
program as per the rules for C++ programs. Sort of the other way from
being defined in terms of. Which in particular means that statements in
the standard about the effect of any construct should not be interpreted
as the effect within some abstract machine (which would yield an
infinitely recursive and impotent definition); instead it is directly
the effect of the construct, and that /is/ the abstract machine.

And the effects of various C++ constructs (and thereby, of the abstract
machine, which is sum total of such effects) have been very carefully
crafted to correspond to and be efficient on actual machines.

C++, and C, are practical engineers'' languages.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


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

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