Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么在二分法中最好计算 a 和 b 之间的中点 c
c = a + (b - a) / 2.
而不是更简单的:
c = (a + b) / 2.
所有变量都是浮点数。
这是为了避免中间计算中任何潜在的溢出/精度损失。