[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
numeric limits patch
It is possible to patch some ``FIXME'' line,
I attach a diff file.
Matteo
Only in graphthing-0.9.4-new/src/: Makefile
diff -r -u graphthing-0.9.4/src/graph2.cc graphthing-0.9.4-new/src/graph2.cc
--- graphthing-0.9.4/src/graph2.cc Tue Dec 30 13:48:26 2003
+++ graphthing-0.9.4-new/src/graph2.cc Mon Mar 22 08:37:11 2004
@@ -4,6 +4,7 @@
#include <queue>
#include <vector>
+#include <limits>
#include "edge.h"
#include "graph.h"
#include "main.h"
@@ -260,7 +261,8 @@
/* Find smallest estimate, and mark it permanently */
Vertex *min = v1;
- int min_val = 999999; /* FIXME: Ugh! */
+ int min_val = std::numeric_limits<int>::max();
+
for (vit = v_begin (); vit != v_end (); ++vit) {
if ((*vit == v1) || ((*vit)->mark >= 0))
continue;
Only in graphthing-0.9.4/src/: gt-bison.tab.cc
Only in graphthing-0.9.4/src/: gt-bison.tab.hh
Only in graphthing-0.9.4/src/: gt-flex.yy.cc
Only in graphthing-0.9.4/src/: lang-bison.tab.cc
Only in graphthing-0.9.4/src/: lang-bison.tab.hh
Only in graphthing-0.9.4/src/: lang-flex.yy.cc
diff -r -u graphthing-0.9.4/src/math.cc graphthing-0.9.4-new/src/math.cc
--- graphthing-0.9.4/src/math.cc Thu Nov 13 07:48:57 2003
+++ graphthing-0.9.4-new/src/math.cc Mon Mar 22 08:38:53 2004
@@ -3,6 +3,8 @@
*/
#include "math.h"
+#include <limits>
+
int Math::choose (int n, int m)
@@ -56,9 +58,14 @@
if (n <= CACHE_MAX)
return cache[n];
- /* FIXME: Uh, oh! Overflow! */
for (i = 13, tot = cache[12]; i <= n; ++i)
- tot *= i;
+ {
+ double test = tot * i ;
+ if (test > std::numeric_limits<int>::max())
+ return -1; // TODO manage Overflow
+ else
+ tot *= i;
+ }
return tot;
}