Defensive break in binary search
This commit is contained in:
parent
f749eb1df8
commit
feb276ccfa
|
@ -151,6 +151,8 @@ function calculateCpmmShareValue(
|
||||||
let kGuess = 0
|
let kGuess = 0
|
||||||
while (Math.abs(k - kGuess) > 0.00000000001) {
|
while (Math.abs(k - kGuess) > 0.00000000001) {
|
||||||
mid = lowAmount + (highAmount - lowAmount) / 2
|
mid = lowAmount + (highAmount - lowAmount) / 2
|
||||||
|
if (mid === lowAmount || mid === highAmount) break
|
||||||
|
|
||||||
kGuess = sellSharesK(pool.YES, pool.NO, p, shares, outcome, mid)
|
kGuess = sellSharesK(pool.YES, pool.NO, p, shares, outcome, mid)
|
||||||
if (kGuess < k) {
|
if (kGuess < k) {
|
||||||
highAmount = mid
|
highAmount = mid
|
||||||
|
|
Loading…
Reference in New Issue
Block a user