Visual Basic .NET 中的 UInt32 数据类型是什么?
VB.NET 中的 UInt32
数据类型是什么?
有人可以告诉我它的位长度以及 UInt32
和 Int32
之间的区别吗?它是整数还是浮点数?
What is the UInt32
datatype in VB.NET?
Can someone inform me about its bit length and the differences between UInt32
and Int32
? Is it an integer or floating point number?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它是一个无符号 32 位整数:
或者您可以查看 文档:
It's an unsigned 32 bit integer:
Or you could just look at the documentation:
UInt32 是 32 位无符号整数。
32 位整数能够保存从 -2,147,483,648 到 2,147,483,647 的值。
但是,由于您指定了无符号整数,因此它只能存储正值。无符号 32 位整数的范围是从 0 到 4,294,967,295。
尝试向 Int 或 UInt 分配超出其范围的值将导致 System.OverflowException。
显然,UInt32 和 Int32 都是整数(不是浮点数),这意味着不允许或存储小数部分。
有趣的是,Integer 和 System.Int32 在 .NET 中是相同的。
出于性能原因,您应该始终尝试对 32 位处理器使用 Int32,对 64 位处理器使用 Int64,因为将这些类型加载到内存或从内存加载将比其他选项更快。
最后,尽量避免使用无符号整数,因为它们不符合 CLS。如果您需要具有 UInt32 上限的纯正整数,最好使用 Int64。无符号整数通常仅用于 API 调用等。
A UInt32 is an unsigned integer of 32 bits.
A 32 bit integer is capable of holding values from -2,147,483,648 to 2,147,483,647.
However, as you have specified an unsigned integer it will only be capable of storing positive values. The range on an unsigned 32 bit integer is from 0 to 4,294,967,295.
Attempts to assign values to an Int or UInt outside of its range will result in an System.OverflowException.
Obviously, both UInt32 and Int32 are integers (not floating point), meaning no decimal portion is permitted or stored.
It may also be interesting to note that Integer and System.Int32 are the same in .NET.
For performance reasons you should always try to use Int32 for 32 bit processors and Int64 for 64 bit processors as loading these types to and from memory will be faster than other options.
Finally, try to avoid use of unsigned integers as they are not CLS compliant. If you need positive only integer that has the upper limit of the UInt32 it is better to use an Int64 instead. Unsigned integers are usually only used for API calls and the like.
它是一个 32 位无符号整数。
It's a 32 Bit unsigned integer.
VB.NET 中的数据类型 注意以下内容:
因此,它是 32 位长的整数。
Data types in VB.NET notes the following:
Thus, it is 32 bits long, an integer.