summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2018-12-12 22:15:10 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2018-12-12 22:15:10 -0800
commit1f016988b2aaf55b6a4e8868bea1bd1c4259195b (patch)
tree78bea969a5ff7d3b072aaa2564784df637edc020
parent2f88284d7b5dd2fc7e9d1141d8818a6349f15194 (diff)
downloadabc-1f016988b2aaf55b6a4e8868bea1bd1c4259195b.tar.gz
abc-1f016988b2aaf55b6a4e8868bea1bd1c4259195b.tar.bz2
abc-1f016988b2aaf55b6a4e8868bea1bd1c4259195b.zip
Fixing float overflow during edge-flow computation in 'if' mapper (change to avoid dependence on the order of additions).
-rw-r--r--src/map/if/ifCut.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c
index 9d884e75..52603671 100644
--- a/src/map/if/ifCut.c
+++ b/src/map/if/ifCut.c
@@ -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;
}