Pagini recente » Monitorul de evaluare | Atasamentele paginii Salsa | Diferente pentru blog/your-bisection-search-is-wrong intre reviziile 17 si 18 | Diferente pentru blog/your-bisection-search-is-wrong intre reviziile 14 si 15 | Diferente pentru blog/your-bisection-search-is-wrong intre reviziile 22 si 23
Nu exista diferente intre titluri.
Diferente intre continut:
*Tomek Czajka(of topcoder fame) pointed out that my final version was buggy as well. I chose the number of iterations to be 120 but that’s way too small. It doesn't work for c = 1e60.*
A double is represented by the mantissa which consists of 52 bits and the exponent which contains 11 bits. One loop iteration either decreases the exponent of our interval by 1 or we find out a new bit of the mantissa. The maximum value of the exponent is 2^11^ and the mantissa has 52 bits. Thus we need 2100 steps to figure out the answer.
A double is represented by the mantissa which consists of 52 bits and the exponent which contains 11 bits(signed). One loop iteration either decreases the exponent of our interval by 1 or we find out a new bit of the mantissa. The maximum value of the exponent is 2^10^ and the mantissa has 52 bits. Thus we need about 1100 steps to figure out the answer.
==code(python) |
def _cubicRoot(c):
lo, hi = 0.0, max(1, c)
for iter in range(0, 2100):
for iter in range(0, 1100):
mid = lo + (hi - lo) / 2
if (mid * mid * mid < c):
lo = mid
Nu exista diferente intre securitate.
Topicul de forum nu a fost schimbat.