gpt4 book ai didi

c# - int、Int16、Int32 和 Int64 之间有什么区别?

转载 作者:IT王子 更新时间:2023-10-29 03:29:42 27 4
gpt4 key购买 nike

intSystem.Int16System.Int32System.Int64有什么区别比他们的大小?

最佳答案

每种类型的整数都有不同的存储容量范围

   Type      Capacity

Int16 -- (-32,768 to +32,767)

Int32 -- (-2,147,483,648 to +2,147,483,647)

Int64 -- (-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807)

正如 James Sutherland 在 his answer 中所述:

int and Int32 are indeed synonymous; int will be a little more familiar looking, Int32 makes the 32-bitness more explicit to those reading your code. I would be inclined to use int where I just need 'an integer', Int32 where the size is important (cryptographic code, structures) so future maintainers will know it's safe to enlarge an int if appropriate, but should take care changing Int32 variables in the same way.

The resulting code will be identical: the difference is purely one of readability or code appearance.

关于c# - int、Int16、Int32 和 Int64 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9696660/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com