Fixing float overflow during edge-flow computation in 'if' mapper (change to avoid dependence on the order of additions).

This commit is contained in:
Alan Mishchenko 2018-12-12 22:15:10 -08:00
parent 2f88284d7b
commit 1f016988b2
1 changed files with 8 additions and 0 deletions

View File

@ -934,7 +934,11 @@ float If_CutAreaFlow( If_Man_t * p, If_Cut_t * pCut )
if ( Flow >= (float)1e32 || AddOn >= (float)1e32 )
Flow = (float)1e32;
else
{
Flow += AddOn;
if ( Flow > (float)1e32 )
Flow = (float)1e32;
}
}
return Flow;
}
@ -968,7 +972,11 @@ float If_CutEdgeFlow( If_Man_t * p, If_Cut_t * pCut )
if ( Flow >= (float)1e32 || AddOn >= (float)1e32 )
Flow = (float)1e32;
else
{
Flow += AddOn;
if ( Flow > (float)1e32 )
Flow = (float)1e32;
}
}
return Flow;
}