惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 零零猪

基于Windows Server 2008 R2的Failover Cluster(故障转移群集)部署Sql Server 2008 AA(主主) 模式群集(第二部分) - 零零猪 基于Windows Server 2008 R2的Failover Cluster(故障转移群集)部署Sql Server 2008 AA(主主) 模式群集(第一部分) - 零零猪 Office 2010众多客户端产品、服务器产品试用下载 免费发短信,短信云计算?? - 零零猪 Asp.Net MVC 1.0 Action Filters Tips 暂时做一个快乐的SOHO族 Asp.Net MVC使用HtmlHelper渲染,并传递FormCollection参数的陷阱 ASP.Net MVC Relational KeyWord 4 Google 【More...】【欢迎补充】 本博客加入“署名-非商业性使用-禁止演绎 2.5 中国大陆”许可协议 Exchange 2007 队列数据库、队列事务日志文件超过临界值(阈值)导致无法接受邮件解决方案 10步完成Windows 2003+SQLServer 2005 群集(Cluster)安装及配置【备案】 C# 3.0通过Linq、Lambda、匿名函数、代理函数实现数据查询 photosynth Trial - 零零猪 MOSS 2007 爬网规则 Contentclass常用属性设置 有用的SharePoint英文资源[持续更新] MOSS2007中Feature对象模型操作 - 零零猪 SQL日志收缩(ZZ) Microsoft photosynth(图片三维展示) - 零零猪 MOSS2007匿名调查列表使用分页符导致的错误分析
整型运算三个恒等式
零零猪 · 2009-11-27 · via 博客园 - 零零猪

整型运算满足如下三个恒等式(不考虑溢出的情况下):
i + j - j === i;
i * j / j === i;
i / j * j + i % j === i
我们可以看出来在这几个式子中,我们可以得出这样的结论。

1、如果我们知道i+j和j,则i的值即可确定。
2、如果我们知道i-j和j,则i的值即可确定。
3、如果我们知道i*j和j,则i的值即可确定。
但我们仅知道i/j和j,不可能确定i的值
而是
4、如果我们知道i/j和i%j还有j的值,则i可以确定。
所以在计算平均值这样的场景,我们仅仅保存i/j和j的值,是不够的。如果加上i%j,则i的值也是可逆的。
所以在除法运算时,为了能够还原计算前的值,我们必须保存余数。

Summarized by Ivony

================================================================
转载要求及授权协议:
作者
零零猪(or)Jiessie327(or)JiessieLiang 
出处http://jiessie327.cnblogs.com/
版权:本文版权归作者所有
转载:欢迎转载,为了尊重作者的劳动成果,在【转载】时请按作者要求,指明文章【出处】或给出【原文链接】,谢谢
================================================================

请遵守署名-非商业性使用-禁止演绎 2.5 中国大陆 License.
================================================================