Defensive break in binary search

This commit is contained in:
James Grugett 2022-04-05 15:16:51 -05:00
parent f749eb1df8
commit feb276ccfa

View File

@ -151,6 +151,8 @@ function calculateCpmmShareValue(
let kGuess = 0
while (Math.abs(k - kGuess) > 0.00000000001) {
mid = lowAmount + (highAmount - lowAmount) / 2
if (mid === lowAmount || mid === highAmount) break
kGuess = sellSharesK(pool.YES, pool.NO, p, shares, outcome, mid)
if (kGuess < k) {
highAmount = mid