64位整数等...

编程入门 行业动态 更新时间:2024-10-25 04:25:32
本文介绍了64位整数等...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我习惯于通过定义自己的整数数据类型来编码。对于 示例: u8bit是无符号字符 u16bit是无符号短字 u32bit是无符号的long或int 随着64位架构的引入,我很好奇 应该用于64位整数。 我已经在Mac上编码了一段时间了,我注意到了一些 数据类型,如__64bitint__ (Don'' t记得确切) XCode我相信是在调用g ++编译器。 c ++标准说什么或建议使用哪个更大的 整数数据类型.. 我担心有些人已经定义了一个int并期待16 或32位我可能实际上是得到(最终)64位。 我希望我的代码能够非常具体地说明它的整数大小 宣布。

I am used to coding by defining my own integer data types. For example: u8bit is unsigned char u16bit is unsigned short u32bit is unsigned long or int With the introduction of 64 bit architectures I''m curious as to what one should use for 64 bit integers. I''ve been codeing on Macs for a while now and I''ve noticed some datatypes like __64bitint__ (Don''t remember exactly) XCode I believe is calling g++ compiler. What does the c++ standard say or recommend that one uses for larger integer datatypes.. I''m worried that some were I''ve defined a int and was expecting a 16 or 32 bit I may actually be getting (eventually) a 64 bit. I want my code to be very specific about the size of the integers it is declaring.

推荐答案

嗨! SpreadTooThin schrieb: Hi! SpreadTooThin schrieb: c ++标准说什么或建议使用哪个更大的 整数数据类型.. What does the c++ standard say or recommend that one uses for larger integer datatypes..

在标准C ++中,long是最大的类型。将来可能会有变化。

In Standard C++ "long" ist the biggest type. Might change in future.

我希望我的代码能够非常具体地说明它是b / b 声明的整数大小。 I want my code to be very specific about the size of the integers it is declaring.

也许这有助于:特定宽度的整数类型的可移植标题。 www.boost/libs/integer/integer.htm Frank

Maybe that helps: a portable header for integer types of specific width. www.boost/libs/integer/integer.htm Frank

SpreadTooThin< bj ******** @ gmailwrote in message ... SpreadTooThin <bj********@gmailwrote in message... 我习惯于通过定义自己的整数数据类型来编码。对于 示例: u8bit是无符号字符 u16bit是无符号短字 u32bit是无符号的long或int 随着64位架构的引入,我很好奇 应该用于64位整数。 我已经在Mac上编码了一段时间了,我注意到了一些 数据类型,如__64bitint__ (Don'' t记得确切) XCode我相信是在调用g ++编译器。 c ++标准说什么或建议使用哪个更大的 整数数据类型.. 我担心有些人已经定义了一个int并期待16 或32位我可能实际上是得到(最终)64位。 我希望我的代码非常具体地说明它是b / b 声明的整数大小。 I am used to coding by defining my own integer data types. For example: u8bit is unsigned char u16bit is unsigned short u32bit is unsigned long or int With the introduction of 64 bit architectures I''m curious as to what one should use for 64 bit integers. I''ve been codeing on Macs for a while now and I''ve noticed some datatypes like __64bitint__ (Don''t remember exactly) XCode I believe is calling g++ compiler. What does the c++ standard say or recommend that one uses for larger integer datatypes.. I''m worried that some were I''ve defined a int and was expecting a 16 or 32 bit I may actually be getting (eventually) a 64 bit. I want my code to be very specific about the size of the integers it is declaring.

您可以通过查看< limitsin 实现来找到一些信息。 尝试(在main()中): std :: cout<<(std :: numeric_limits< long long> :: digits)<< std :: endl; 如果它编译,你知道你的类型是''long long''。检查它的位数。 - Bob R POVrookie

You might find some information by looking through <limitsin your implementation. Try ( in main() ): std::cout <<(std::numeric_limits<long long>::digits)<<std::endl; If it compiles, you know you have type ''long long''. Check it''s bit size. -- Bob R POVrookie

8月15日上午9:56,SpreadTooThin< bjob​​rie ... @ gmailwrote: On Aug 15, 9:56 am, SpreadTooThin <bjobrie...@gmailwrote: 我习惯通过定义编码我自己的整数数据类型。 I am used to coding by defining my own integer data types.

对于它的价值 - 这可能不会太多 - 除了特定的 数据的二进制格式,或者 大容器占用的空间是至关重要的,很少有理由指定 的确切宽度。它只是建议任何人看到你的代码,你没有理解这些类型没有设置宽度的原因 首先 - 没有做到好印象: - <。

For what it''s worth - which might not be much - except in specific situations where the binary format of data, or the space taken by large containers is critical, there''s rarely a good reason to specify exact widths. It simply suggests to anyone seeing your code that you have not understood the reasons for the types not being set-width in the first place - doesn''t make a good impression :-<.

我担心有些人我已经定义了一个int并期待16 或32位我可能实际上得到(最终)64位。 我希望我的代码非常具体地说明它是b / b 声明的整数的大小。 I''m worried that some were I''ve defined a int and was expecting a 16 or 32 bit I may actually be getting (eventually) a 64 bit. I want my code to be very specific about the size of the integers it is declaring.

那么,为什么呢? ;-)获得64位值的后果会让你担心吗? Tony

So, why? ;-) What would be the consequences of getting 64 bit values that worry you? Tony

更多推荐

64位整数等...

本文发布于:2023-11-30 05:37:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648905.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:整数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!