注意溢出问题
摘要:
sqrt(x)中low, high, mid均要设为long类型,原因是在运行过程中若采用int类型,则mid*mid的结果采用int类型可能会溢出。public class Solution { public int mySqrt(int x) { if (x x) { ... 阅读全文
posted @ 2015-11-19 10:57 ShinningWu 阅读(75) 评论(0) 推荐(0) 编辑
posted @ 2015-11-19 10:57 ShinningWu 阅读(75) 评论(0) 推荐(0) 编辑
posted @ 2015-11-19 10:54 ShinningWu 阅读(165) 评论(0) 推荐(0) 编辑