long 数据类型可以容纳的最大值是多少
我相信这个问题有点开放式,但我正在认真挣扎。我不断地出现溢出。
我有两个多头。第一个设置为 16552800。我可以添加 32760 没有问题。但是,当我将 32820 添加到 is 时,出现溢出错误。
有什么想法吗?!?!?!
谢谢!!!
I believe this question is sort of open ended, but I am seriously struggling. I keep getting an over flow.
I have two longs. The first is set to 16552800. I can add 32760 to it no problem. However I get an overflow error when I add 32820 to is.
Any ideas?!?!?!
Thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Visual Basic 6 中的 long 为 32 位,范围为 2,147,483,648 到 2,147,483,647。你还远未达到这个极限。在 VB.NET 中它是 64 位。
当您添加大于或等于 215 = 32768 的数字时,您似乎会收到错误。您可以尝试 32767 和 32768,看看这是否是错误开始发生的点?
你确定溢出是来自加法吗?我怀疑您正在尝试将 32820 分配给有符号整数(范围 -32768 到 +32767),正是这个分配给出了溢出,而不是加法。
A long in Visual Basic 6 is 32 bits and has a range from 2,147,483,648 to 2,147,483,647. You are nowhere near this limit. In VB.NET it is 64 bit.
It seems that you get an error when you add a number greater than or equal to 215 = 32768. Could you try 32767 and 32768 and see if that is the point at which the error starts occurring?
Are you sure that the overflow is coming from the addition? I suspect that you are trying to assign 32820 to a signed integer (range -32768 to +32767), and it's this assignment that gives the overflow, not the addition.