3 ms·
The two loop invariants would be: 1.0 == total + delta * 2 and delta > 0, so the while condition would never be false. The amount of memory required to store t
by spacehome 11y ago
The two loop invariants would be: 1.0 == total + delta * 2 and delta > 0, so the while condition would never be false.
The amount of memory required to store the delta variable should be at least log_2(n) bits, where n is the iteration number. This has to be true, regardless of the implementation details of bigFloat because delta has to take on n distinct values. Eventually it exhausts the memory of the machine.
It seems pretty straightforward, unless your compiler is smart enough to see what's going on and optimize the body of the loop away, in which case it wouldn't terminate.