diff liboctave/lo-utils.cc @ 6490:0ad7655cf2bc

[project @ 2007-04-05 02:44:34 by jwe]
author jwe
date Thu, 05 Apr 2007 02:44:35 +0000
parents e5ed0d1edddc
children 935d23e16951
line wrap: on
line diff
--- a/liboctave/lo-utils.cc	Wed Apr 04 18:59:19 2007 +0000
+++ b/liboctave/lo-utils.cc	Thu Apr 05 02:44:35 2007 +0000
@@ -26,10 +26,10 @@
 #include <config.h>
 #endif
 
-#include <climits>
 #include <cstdlib>
 #include <cstdio>
 
+#include <limits>
 #include <string>
 
 #ifdef HAVE_UNISTD_H
@@ -48,15 +48,14 @@
 // this function.
 
 // Sometimes you need a large integer, but not always.
-// FIXME -- INT_MAX and INT_MIN are probably not right for 64-bits.
 
 octave_idx_type
 NINTbig (double x)
 {
-  if (x > INT_MAX)
-    return INT_MAX;
-  else if (x < INT_MIN)
-    return INT_MIN;
+  if (x > std::numeric_limits<octave_idx_type>::max ())
+    return std::numeric_limits<octave_idx_type>::max ();
+  else if (x < std::numeric_limits<octave_idx_type>::min ())
+    return std::numeric_limits<octave_idx_type>::min ();
   else
     return static_cast<octave_idx_type> ((x > 0) ? (x + 0.5) : (x - 0.5));
 }
@@ -64,10 +63,10 @@
 int
 NINT (double x)
 {
-  if (x > INT_MAX)
-    return INT_MAX;
-  else if (x < INT_MIN)
-    return INT_MIN;
+  if (x > std::numeric_limits<int>::max ())
+    return std::numeric_limits<int>::max ();
+  else if (x < std::numeric_limits<int>::min ())
+    return std::numeric_limits<int>::min ();
   else
     return static_cast<int> ((x > 0) ? (x + 0.5) : (x - 0.5));
 }