本文介绍了C / C ++的无符号整数溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我读有关整数安全的文章。
这里的链接:
http://ptgmedia.pearsoncmg.com/images/0321335724/samplechapter/seacord_ch05.pdf
i'm reading an article about integer security .here's the link:http://ptgmedia.pearsoncmg.com/images/0321335724/samplechapter/seacord_ch05.pdf
在166页,有说:
在无符号运算绝不能溢流,因为一个计算
结果是不能重新由所得的无符号整数psented $ P $
类型被减小模数,以比所述较大者的数目
可再通过将得到的式psented $ P $最大值
这是什么意思? AP preciate答复。
What does it mean? appreciate for reply.
推荐答案
这意味着值环绕。
UINT_MAX + 1 == 0
UINT_MAX + 2 == 1
UINT_MAX + 3 == 2
..等等
为纽带说,这就像模运算符:http://en.wikipedia.org/wiki/Modulo_operation
As the link says, this is like the modulo operator: http://en.wikipedia.org/wiki/Modulo_operation
这篇关于C / C ++的无符号整数溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!