整数或长溢出... [英] integer or long overflow...

查看:45
本文介绍了整数或长溢出...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你增加一个整数或长数据类型中包含的数字超过其容量的
时,会发生什么?我遇到过这种情况,它继续正好继续。当它达到

限制时,它只是简单地滚动吗?好奇。


d

When you increase the number contained within an integer or long data type
beyond its capacity, what happens? I''ve run into this situation, and it
continues right along. Is it simply just rolling over when it gets to its
limit? Curious.

d

推荐答案

deancoo写道:
deancoo wrote:
当你增加包含在整数或长数据类型中的数字超出其容量,会发生什么?我遇到了这种情况,它一直在继续。当它达到其限制时,它只是简单地滚动吗?好奇。
When you increase the number contained within an integer or long data type
beyond its capacity, what happens? I''ve run into this situation, and it
continues right along. Is it simply just rolling over when it gets to its
limit? Curious.




我相信/怀疑像许多边缘效应一样在C ++中它是

undefined。然而,一个2'的赞美架构(如大多数C ++似乎是b $ b环境)将会一直保持正常 - 没有

异常/陷阱,比如专用浮动点硬件

遇到问题或者说除以零。


如果你增加一个有符号整数,则得到2的恭维>
类型(int或long)超出它的限制,它变成一个非常大的负数

数字并保持增加数字 - 变得不那么消极,走向零。



I believe/suspect that like so many "edge effects" in C++ it is left
undefined. However, a 2''s compliment architecture (as most C++
environments seem to be) will simply keep right on going - no
exception/trap as from say dedicated floating point hardware
experiencing a problem or say dividing by zero.

The gotcha with 2''s compliment is that if you increase a signed integer
type (int or long) beyond it''s limit, it becomes a very large negative
number and keeps "increasing" - becoming less negative, headed towards zero.




" deancoo" < S2 ******* @ yahoo.ca>在消息中写道

news:Tl8Wd.2338

"deancoo" <s2*******@yahoo.ca> wrote in message
news:Tl8Wd.2338


KI2.178@clgrps12 ...
KI2.178@clgrps12...
当你增加其中包含的数字时一个整数或长数据类型超出其容量,会发生什么?我遇到了这种情况,它一直在继续。当它达到其限制时,它只是简单地滚动吗?好奇。

d
When you increase the number contained within an integer or long data type
beyond its capacity, what happens? I''ve run into this situation, and it
continues right along. Is it simply just rolling over when it gets to its
limit? Curious.

d




emum类型怎么样?最终它们被存储和比较为

数字,但它们的大小是多少?简短?


d



And how about emum types? Ultimately they''re stored and compared as
numbers, but what is their size? Short?

d


这篇关于整数或长溢出...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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