64位数据类型 [英] 64-bit datatype

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

问题描述

我正在编写的程序需要64位数据类型。在gcc 4.1.1上我可以用''long long''整数编译
,但我知道这不是ANSI

标准类型,我很担心可移植性问题 - 特别是在

32位机器上。因为我似乎无法在任何地方找到这种信息

:是否有我应该使用的特定数据类型以及我如何确保我选择正确的
每台机器的数据类型?


干杯,


-Jake

A program I''m writing requires a 64-bit datatype. On gcc 4.1.1 I can
compile with ''long long'' integers but I''m aware that this is not an ANSI
standard type and am worried about portability issues - especially on
32-bit machines. Since I can''t seem to find this sort of information
anywhere: is there a particular datatype I should be using and how do I
ensure that I choose the correct datatype for each machine?

Cheers,

-Jake

推荐答案

Jake Langham写道:
Jake Langham wrote:

我正在编写的程序需要64位数据类型。在gcc 4.1.1上我可以用''long long''整数编译
,但我知道这不是ANSI

标准类型
A program I''m writing requires a 64-bit datatype. On gcc 4.1.1 I can
compile with ''long long'' integers but I''m aware that this is not an ANSI
standard type



是的,确实如此。已经有七年多了。

它不是标准的C89类型。

Yes, it is. And has been for more than seven years.
It is not a standard C89 type.


我担心可移植性问题 - 特别是关于

32位机器。因为我似乎无法找到这种信息
and am worried about portability issues - especially on
32-bit machines. Since I can''t seem to find this sort of information



32位机器使用long long没有任何缺点。

Hell ,long long可以轻松用于8位,12位甚至1位

可寻址机器。

32-bit machines are no drawback to using long long.
Hell, long long could easily be used on 8-bit, or 12-bit, or even 1-bit
addressable machines.


anywhere :我应该使用一种特定的数据类型吗?我如何确保为每台机器选择正确的数据类型

anywhere: is there a particular datatype I should be using and how do I
ensure that I choose the correct datatype for each machine?



如果你不习惯让程序可以移植到C89编译器,那么<​​br />
不能长时间提供,那么你就被困住了很久。

If you are stuck with making programs portable to C89 compilers that
don''t provide long long, then you''re stuck with long.


Jake Langham在04/25/07 14:25写道:
Jake Langham wrote On 04/25/07 14:25,:

一个程序我写的需要64位数据类型。在gcc 4.1.1上我可以用''long long''整数编译
,但我知道这不是ANSI

标准类型,我很担心可移植性问题 - 特别是在

32位机器上。因为我似乎无法在任何地方找到这种信息

:是否有我应该使用的特定数据类型以及我如何确保我选择正确的
每台机器的数据类型?
A program I''m writing requires a 64-bit datatype. On gcc 4.1.1 I can
compile with ''long long'' integers but I''m aware that this is not an ANSI
standard type and am worried about portability issues - especially on
32-bit machines. Since I can''t seem to find this sort of information
anywhere: is there a particular datatype I should be using and how do I
ensure that I choose the correct datatype for each machine?



`long long''*是ANSI C数据类型 - 如果你的编译器

符合当前的C99数据类型。 ISO / ANSI标准。 'long long''

至少64位宽,也许更宽。


C99的使用速度比C89 / 90慢,<但是,支持它的编译器变得比它们曾经的b $ b b变得更平常。此外,许多前C99编译器提供了long long'

作为扩展。这是相当广泛的可用。


可移植性的担忧应该是关于某些可能的目标环境的定义良好或不确定的b $ b b。如果你对b

$ b有一个合理的概念,你可以检查C99或C90扩展编译器是否是
可用于他们 - 例如,你有多少目标

没有gcc实现?


最后,如果你根本不能依赖`long很长一段时间你需要用更窄的

类型来模拟必要的操作。这有多难取决于你需要什么样的操作?如果你需要的只是点翻,那就更容易死了,如果需要加/减$ /比较,你需要加/减$ / b,如果你需要分数/模数,那就更难了,如果你需要

就像printf()和scanf()支持那样令人讨厌。


-
Er ********* @ sun.com


Eric Sosman< Er ********* @ sun.comwrites:
Eric Sosman <Er*********@sun.comwrites:

Jake Langham在04/25/07 14:25写道:
Jake Langham wrote On 04/25/07 14:25,:

>我正在编写的程序需要64位数据类型。在gcc 4.1.1上我可以用''long long''整数编译,但我知道这不是ANSI
标准类型,我担心可移植性问题 - 特别是在
32位机器。因为我似乎无法在任何地方找到这种信息:是否有我应该使用的特定数据类型以及如何确保为每台机器选择正确的数据类型?
>A program I''m writing requires a 64-bit datatype. On gcc 4.1.1 I can
compile with ''long long'' integers but I''m aware that this is not an ANSI
standard type and am worried about portability issues - especially on
32-bit machines. Since I can''t seem to find this sort of information
anywhere: is there a particular datatype I should be using and how do I
ensure that I choose the correct datatype for each machine?



`long long''*是ANSI C数据类型 - 如果你的编译器

符合当前的C99数据类型。 ISO / ANSI标准。 'long long''

至少64位宽,也许更宽。


C99的使用速度比C89 / 90慢,<但是,支持它的编译器变得比它们曾经的b $ b b变得更平常。此外,许多前C99编译器提供了long long'

作为扩展。它相当广泛。


`long long'' *is* an ANSI C data type -- if your compiler
conforms to the current "C99" ISO/ANSI Standard. `long long''
is at least 64 bits wide, perhaps wider.

The uptake of C99 has been slower than that of C89/90,
but compilers that support it are becoming commoner than they
used to be. Also, many pre-C99 compilers provided `long long''
as an extension. It is fairly widely available.



[...]


我似乎记得有些微软编译器提供了64位

整数类型,但称之为long long以外的东西。


如果你关心这些编译器的可移植性,你可以使用

某种带有typedef的#ifdef:


#ifdef _SOME_MS_SPECIFIC_SYMBOL

typedef _SOME_MS_SPECIFIC_TYPE int64;

#else

typedef long long int64;

#endif


-

Keith Thompson(The_Other_Keith) ks *** @ mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *< http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。

- Antony Jay和Jonathan Lynn,是部长

[...]

I seem to recall that some Microsoft compilers provide a 64-bit
integer type, but call it something other than "long long".

If you care about portability to such compilers, you can probably use
some kind of #ifdef with a typedef:

#ifdef _SOME_MS_SPECIFIC_SYMBOL
typedef _SOME_MS_SPECIFIC_TYPE int64;
#else
typedef long long int64;
#endif

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


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

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