This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

autogenerated version of numeric_limits (with enquire changes)


Hello,

Here is a patch to enquire.c that can be used to generate the limits file.

A modification of the limits file that I posted the other day can be used 
with this enquire program to generate the limits file during the build (
maybe when float.h and limits.h are generated).

Assuming one is in the gcc/cp directory, and that is where limits.in is,
the limits file would be created with the following command line:

../enquire -n | sed -f - limits.in > limits

limits.in is included in this note after the enquire.c patch:

Peeter Joot
http://www.accessv.com/~peeter                               peeter@accessv.com

------------------------------------------------------------------------------

--- egcs-1.0.1.orig/gcc/enquire.c	Mon Aug 11 11:57:06 1997
+++ egcs-1.0.1/gcc/enquire.c	Thu Feb 19 02:24:35 1998
@@ -479,9 +479,11 @@
 Procedure f_define ARGS((char *desc, char *extra, char *sort, char *name,
 			 int prec, Long_double val, char *mark));
 Procedure i_define ARGS((char *desc, char *extra, char *sort, char *name,
-			 long val, long lim, long req, char *mark));
+			 long val, long lim, long req, 
+			 char *mark));
 Procedure u_define ARGS((char *desc, char *extra, char *sort, char *name,
-			 unsigned long val, unsigned long req, char *mark));
+			 unsigned long val, unsigned long req, 
+                         char *mark));
 
 #ifdef NO_SIG  /* There's no signal(), or setjmp/longjmp() */
 
@@ -505,6 +507,7 @@
 int V= 0,	/* verbose */
     L= 0,	/* produce limits.h */
     F= 0,	/* produce float.h  */
+    N= 0,	/* produce info for numeric_limits<> class */
     bugs=0;	/* The number of (possible) bugs in the output */
 
 char co[4], oc[4]; /* Comment starter and ender symbols */
@@ -675,6 +678,7 @@
 				      case 'v': V=1; break;
 				      case 'l': L=1; break;
 				      case 'f': F=1; break;
+				      case 'n': N=1; break;
 				      default: bad=1; break;
 				}
 			}
@@ -685,7 +689,7 @@
 	}
 	if (bad) {
 		fprintf(stderr,
-			"Usage: %s [-vlf]\n  v=Verbose l=Limits.h f=Float.h\n",
+			"Usage: %s [-vlf]\n  v=Verbose l=Limits.h f=Float.h n=numeric_limits\n",
 			argv[0]);
 		exit(1);
 	}
@@ -696,7 +700,8 @@
 		co[3]= '\0'; oc[3]= '\0';
 	} else {
 		co[0]= '\0'; oc[0]= '\0';
-		V=1;
+		if (!N)
+			V=1;
 	}
 
 	if (L) printf("%slimits.h%s\n", co, oc);
@@ -705,6 +710,8 @@
 		printf ("#ifndef _FLOAT_H___\n");
 		printf ("#define _FLOAT_H___\n");
 	}
+	if (N) L=F=1;
+	else
 #ifdef ID
 	printf("%sProduced on %s by enquire version %s, CWI, Amsterdam%s\n",
 	       co, ID, VERSION, oc);
@@ -776,7 +783,7 @@
 			co, (total+511)/512, oc);
 	}
 #endif
-	if (F) {
+	if (F && !N) {
 		printf ("#endif %s _FLOAT_H___%s\n", co, oc);
 	}
 	farewell(bugs);
@@ -796,21 +803,41 @@
 	printf("%s\n", oc);
 }
 
+Procedure l_digits10(name, max)
+     char * name; unsigned long max; {
+     int digits;
+	
+	for ( digits=0 ; max > 10 ; digits++, max /= 10 ) ;
+	printf("s/@%s_digits10@/%i/g\n", name, digits);
+}
+
 Procedure i_define(desc, extra, sort, name, val, lim, req, mark)
      char *desc, *extra, *sort, *name; long val, lim, req; char *mark; {
 	/* Produce a #define for a signed int type */
-	describe(desc, extra);
-	printf("#undef %s%s\n", sort, name);
+	if (!N) {
+		describe(desc, extra);
+		printf("#undef %s%s\n", sort, name);
+	}
 	if (val >= 0) {
-		printf("#define %s%s %ld%s\n", sort, name, val, mark);
+		if (!N)
+			printf("#define %s%s %ld%s\n", sort, name, val, mark);
+		else
+			printf("s/@%s%s@/%ld%s/g\n", sort, name, val, mark);
 	} else if (val + lim < 0) {
 		/* We may not produce a constant like -1024 if the max
 		   allowable value is 1023. It has then to be output as
 		   -1023-1. lim is the max allowable value.  */
-		printf("#define %s%s (%ld%s%ld%s)\n",
-		       sort, name, -lim, mark, val+lim, mark);
+		if (!N)
+			printf("#define %s%s (%ld%s%ld%s)\n",
+			       sort, name, -lim, mark, val+lim, mark);
+		else
+			printf("s/@%s%s@/(%ld%s%ld%s)/g\n",
+			       sort, name, -lim, mark, val+lim, mark);
 	} else {
-		printf("#define %s%s (%ld%s)\n", sort, name, val, mark);
+		if (!N)
+			printf("#define %s%s (%ld%s)\n", sort, name, val, mark);
+		else
+			printf("s/@%s%s@/(%ld%s)/g\n", sort, name, val, mark);
 	}
 	/* If VERIFY is not set, val and req are just the same value;
 	   if it is set, val is the value as calculated, and req is
@@ -827,9 +854,14 @@
 Procedure u_define(desc, extra, sort, name, val, req, mark)
      char *desc, *extra, *sort, *name; unsigned long val, req; char *mark; {
 	/* Produce a #define for an unsigned value */
-	describe(desc, extra);
-	printf("#undef %s%s\n", sort, name);
-	printf("#define %s%s %lu%s%s\n", sort, name, val, U, mark);
+	if (!N) {
+		describe(desc, extra);
+		printf("#undef %s%s\n", sort, name);
+	}
+	if (!N)
+		printf("#define %s%s %lu%s%s\n", sort, name, val, U, mark);
+	else
+		printf("s/@%s%s@/%lu%s%s/g\n", sort, name, val, U, mark);
 	if (val != req) {
 		printf("%s*** Verify failed for above #define!\n", co);
 		printf("       Compiler has %lu for value%s\n\n", req, oc);
@@ -842,14 +874,16 @@
      char *desc, *extra, *sort, *name; int precision;
      Long_double val; char *mark; {
 	/* Produce a #define for a float/double/long double */
-	describe(desc, extra);
-	printf ("#undef %s%s\n", sort, name);
+	if (!N) {
+		describe(desc, extra);
+		printf ("#undef %s%s\n", sort, name);
+	}
 	if (stdc) {
 #ifdef NO_LONG_DOUBLE_IO
 		static int union_defined = 0;
 		if (sizeof(double) != sizeof(Long_double)
 		    && !strcmp(sort, "LDBL")) {
-			if (!union_defined) {
+			if (!union_defined && !N) {
 				printf("#ifndef __LDBL_UNION__\n");
 				printf("#define __LDBL_UNION__\n");
 				printf("union __convert_long_double {\n");
@@ -859,22 +893,43 @@
 				printf("#endif\n");
 				union_defined = 1;
 			}
-			printf("#define %s%s %s\n",
-			       sort, name, fake_f_rep("long double", val));
+			if (!N)
+				printf("#define %s%s %s\n", sort, name, 
+					fake_f_rep("long double", val));
+			else
+				printf("s/@%s%s@/%s/g\n", sort, name, 
+					fake_f_rep("long double", val));
 		} else {
-			printf("#define %s%s %s%s\n",
-			       sort, name, f_rep(precision, val), mark);
+			if (!N)
+				printf("#define %s%s %s%s\n", sort, name, 
+					f_rep(precision, val), mark);
+			else
+				printf("s/@%s%s@/%s%s/g\n", sort, name, 
+					f_rep(precision, val), mark);
 		}
 #else
-		printf("#define %s%s %s%s\n",
-		       sort, name, f_rep(precision, val), mark);
+		if (!N)
+			printf("#define %s%s %s%s\n", sort, name, 
+				f_rep(precision, val), mark);
+		else
+			printf("s/@%s%s@/%s%s/g\n", sort, name, 
+				f_rep(precision, val), mark);
 #endif
 	} else if (*mark == 'F') {
 		/* non-ANSI C has no float constants, so cast the constant */
-		printf("#define %s%s ((float)%s)\n",
-		       sort, name, f_rep(precision, val));
+		if (!N)
+			printf("#define %s%s ((float)%s)\n", sort, name, 
+				f_rep(precision, val));
+		else
+			printf("s/@%s%s@/((float)%s)/g\n", sort, name, 
+				f_rep(precision, val));
 	} else {
-		printf("#define %s%s %s\n", sort, name, f_rep(precision, val));
+		if (!N)
+			printf("#define %s%s %s\n", sort, name, 
+				f_rep(precision, val));
+		else
+			printf("s/@%s%s@/%s/g\n", sort, name, 
+				f_rep(precision, val));
 	}
 	Vprintf("\n");
 }
@@ -1440,6 +1495,8 @@
 			i_define(D_SCHAR_MIN, "", "SCHAR", "_MIN",
 				 (long) char_min, (long) maxint,
 				 (long) SCHAR_MIN, "");
+			if (N) 
+				l_digits10("schar", char_max);
 		} else {
 			if (sizeof(char) == sizeof(int)) {
 				u_define(D_UCHAR_MAX, "", "UCHAR", "_MAX",
@@ -1450,6 +1507,8 @@
 					 (long) char_max, 0L,
 					 (long) UCHAR_MAX, "");
 			}
+			if (N) 
+				l_digits10("uchar", char_max);
 		}
 
 		if (c_signed) {
@@ -1473,6 +1532,8 @@
 					 (long) char_max, 0L,
 					 (long) UCHAR_MAX, "");
 			}
+			if (N) 
+				l_digits10("uchar", char_max);
 #endif
 		} else {
 #ifndef NO_SC
@@ -1500,6 +1561,8 @@
 			i_define(D_SCHAR_MAX, "", "SCHAR", "_MAX",
 				 (long) char_max, 0L,
 				 (long) SCHAR_MAX, "");
+			if (N) 
+				l_digits10("schar", char_max);
 #endif /* NO_SC */
 		}
 	}
@@ -2067,6 +2130,7 @@
 	if (L) i_define(D_INT_MIN, INT, Iname, "_MIN",
 			(long) int_min, (long) (PASS==1?maxint:int_max),
 			(long) I_MIN, IMARK);
+	if (N) l_digits10(INT, int_max);
 
 	if(int_max < 0) { /* It has happened */
 		eek_a_bug("signed integral comparison faulty?");
@@ -2117,6 +2181,7 @@
 				 (unsigned long) u_max,
 				 (unsigned long) U_MAX, IMARK);
 		}
+		if (N) l_digits10("u" INT, u_max);
 	}
 #endif
 }





// egcs-1.0.1.orig/gcc/cp/limits.in:

#if !defined(__limits_h)
#define __limits_h

template <class T> class numeric_limits;

enum float_round_style
{
	round_indeterminate		= -1,
	round_toward_zero		= 0,
	round_to_nearest		= 1,
	round_toward_infinity		= 2,
	round_toward_neg_infinity	= 3
};

template <class T> class numeric_limits
{
public:
	static const bool is_specialized;
	static T min();
	static T max();
	static const int digits;
	static const int digits10;
	static const bool is_signed;
	static const bool is_integer;
	static const bool is_exact;
	static const int radix;
	static T epsilon();
	static T round_error();

	static const int min_exponent;
	static const int min_exponent10;
	static const int max_exponent;
	static const int max_exponent10;

	static const bool has_infinity;
	static const bool has_quite_NaN;
	static const bool has_signaling_NaN;
	static const bool has_denorm;
	static T infinity();
	static T quiet_NaN();
	static T signaling_NaN();
	static T denorm_min();

	static const bool is_iec559;
	static const bool is_bounded;
	static const bool is_modulo;

	static const bool traps;
	static const bool tinyness_before;
	static const float_round_style round_style;
};

class numeric_limits<bool>
{
public:
	static const bool is_specialized = true;

	inline static bool min() { return false; }
	inline static bool max() { return true; }

	static const int digits		= 1;
	static const int digits10	= 1;
//	static const int digits		= @bool_digits@;
//	static const int digits10	= @bool_digits10@;

	static const bool is_signed 	= false;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static bool epsilon() { return false; }
	inline static bool round_error() { return false; }

	static const int min_exponent	= false;
	static const int min_exponent10	= false;
	static const int max_exponent	= false;
	static const int max_expontent10 = false;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static bool infinity() { return false; } 
	inline static bool quiet_NaN() { return false; } 
	inline static bool signaling_NaN() { return false; } 
	inline static bool denorm_min() { return false; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= false;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_indeterminate;
};

//
// Character specializations.
//
class numeric_limits<char>
{
public:
	static const bool is_specialized = true;

	inline static char min() { return @CHAR_MIN@; } // CHAR_MIN
	inline static char max() { return @CHAR_MAX@; } // CHAR_MAX

#ifdef __CHAR_UNSIGNED__
	static const int digits		= sizeof(char)*@CHAR_BIT@;
#else
	static const int digits		= sizeof(char)*@CHAR_BIT@ -1;
#endif
#ifdef __CHAR_UNSIGNED__
	static const int digits10	= @uchar_digits10@;
#else
	static const int digits10	= @schar_digits10@;
#endif

#ifdef __CHAR_UNSIGNED__
	static const bool is_signed 	= false;
#else
	static const bool is_signed 	= true;
#endif
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static char epsilon() { return 0; }
	inline static char round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static char infinity() { return 0; } 
	inline static char quiet_NaN() { return 0; } 
	inline static char signaling_NaN() { return 0; } 
	inline static char denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

class numeric_limits<signed char>
{
public:
	static const bool is_specialized = true;

	inline static signed char min() { return @CHAR_MIN@; } // CHAR_MIN
	inline static signed char max() { return @CHAR_MAX@; } // CHAR_MAX

	static const int digits		= sizeof(signed char)*@CHAR_BIT@ -1;
	static const int digits10	= @schar_digits10@;

	static const bool is_signed 	= true;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static signed char epsilon() { return 0; }
	inline static signed char round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static signed char infinity() { return 0; } 
	inline static signed char quiet_NaN() { return 0; } 
	inline static signed char signaling_NaN() { return 0; } 
	inline static signed char denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

class numeric_limits<unsigned char>
{
public:
	static const bool is_specialized = true;

	inline static unsigned char min() { return 0; }
	inline static unsigned char max() { return @UCHAR_MAX@; } // UCHAR_MAX

	static const int digits		= sizeof(unsigned char)*@CHAR_BIT@;
	static const int digits10	= @uchar_digits10@;

	static const bool is_signed 	= false;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static signed char epsilon() { return 0; }
	inline static signed char round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static signed char infinity() { return 0; } 
	inline static signed char quiet_NaN() { return 0; } 
	inline static signed char signaling_NaN() { return 0; } 
	inline static signed char denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

#if 0
class numeric_limits<wchar_t>
{
public:
	static const bool is_specialized = true;

	inline static unsigned char min() { return @WCHAR_MIN@; } // WCHAR_MIN
	inline static unsigned char max() { return @WCHAR_MAX@; } // WCHAR_MAX

	static const int digits		= sizeof(wchar_t)*@CHAR_BIT@;
	static const int digits10	= @wchar_t_digits10@;

	static const bool is_signed 	= false; // ?
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static signed char epsilon() { return 0; }
	inline static signed char round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static signed char infinity() { return 0; } 
	inline static signed char quiet_NaN() { return 0; } 
	inline static signed char signaling_NaN() { return 0; } 
	inline static signed char denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};
#endif

//
// Integer specializations.
//
class numeric_limits<short>
{
public:
	static const bool is_specialized = true;

	inline static short min() { return @SHRT_MIN@; } // SHRT_MIN
	inline static short max() { return @SHRT_MAX@; } // SHRT_MAX

	static const int digits		= sizeof(short)*@CHAR_BIT@ -1;
	static const int digits10	= @short_digits10@;

	static const bool is_signed 	= true;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static short epsilon() { return 0; }
	inline static short round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static short infinity() { return 0; } 
	inline static short quiet_NaN() { return 0; } 
	inline static short signaling_NaN() { return 0; } 
	inline static short denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

class numeric_limits<unsigned short>
{
public:
	static const bool is_specialized = true;

	inline static unsigned short min() { return 0; }
	inline static unsigned short max() { return @USHRT_MAX@; } // USHRT_MAX

	static const int digits		= sizeof(short)*@CHAR_BIT@;
	static const int digits10	= @ushort_digits10@;

	static const bool is_signed 	= false;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static unsigned short epsilon() { return 0; }
	inline static unsigned short round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static unsigned short infinity() { return 0; }
	inline static unsigned short quiet_NaN() { return 0; } 
	inline static unsigned short signaling_NaN() { return 0; } 
	inline static unsigned short denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

class numeric_limits<int>
{
public:
	static const bool is_specialized = true;

	inline static int min() { return @INT_MIN@; } // INT_MIN
	inline static int max() { return @INT_MAX@; } // INT_MAX

	static const int digits		= sizeof(int)*@CHAR_BIT@ -1;
	static const int digits10	= @int_digits10@;

	static const bool is_signed 	= true;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static int epsilon() { return 0; }
	inline static int round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static int infinity() { return 0; } 
	inline static int quiet_NaN() { return 0; } 
	inline static int signaling_NaN() { return 0; } 
	inline static int denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

class numeric_limits<unsigned int>
{
public:
	static const bool is_specialized = true;

	inline static unsigned int min() { return @INT_MIN@; } // INT_MIN
	inline static unsigned int max() { return @INT_MAX@; } // INT_MAX

	static const int digits		= sizeof(int)*@CHAR_BIT@;
	static const int digits10	= @uint_digits10@;

	static const bool is_signed 	= false;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static unsigned int epsilon() { return 0; }
	inline static unsigned int round_error() { return 0; }

	static const unsigned int min_exponent	= 0;
	static const unsigned int min_exponent10	= 0;
	static const unsigned int max_exponent	= 0;
	static const unsigned int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static unsigned int infinity() { return 0; } 
	inline static unsigned int quiet_NaN() { return 0; } 
	inline static unsigned int signaling_NaN() { return 0; } 
	inline static unsigned int denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

class numeric_limits<long>
{
public:
	static const bool is_specialized = true;

#if defined (__alpha__) || (defined (__sparc_v9__) && defined (__arch64__))
	inline static long min() { return (-9223372036854775807L-1); } // LONG_MIN
	inline static long max() { return 9223372036854775807L; } // LONG_MAX
#else
	inline static long min() { return @LONG_MIN@; } // LONG_MIN
	inline static long max() { return @LONG_MAX@; } // LONG_MAX
#endif

	static const int digits		= sizeof(long)*@CHAR_BIT@ -1;
#if defined (__alpha__) || (defined (__sparc_v9__) && defined (__arch64__))
	static const int digits10	= 18;
#else
	static const int digits10	= @long_digits10@;
#endif

	static const bool is_signed 	= true;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static long epsilon() { return 0; }
	inline static long round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static long infinity() { return 0; } 
	inline static long quiet_NaN() { return 0; } 
	inline static long signaling_NaN() { return 0; } 
	inline static long denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

class numeric_limits<unsigned long>
{
public:
	static const bool is_specialized = true;

	inline static unsigned long min() { return 0; }
#if defined (__alpha__) || (defined (__sparc_v9__) && defined (__arch64__))
	inline static unsigned long max() { return 18446744073709551615uL; } // ULONG_MAX
#else
	inline static unsigned long max() { return @ULONG_MAX@; } // ULONG_MAX
#endif

	static const int digits		= sizeof(unsigned long)*@CHAR_BIT@;
#if defined (__alpha__) || (defined (__sparc_v9__) && defined (__arch64__))
	static const int digits10	= 19;
#else
	static const int digits10	= @ulong_digits10@;
#endif

	static const bool is_signed 	= false;
	static const bool is_integer 	= true;
	static const bool is_exact 	= true;

	static const int radix 		= 2;
	inline static long epsilon() { return 0; }
	inline static long round_error() { return 0; }

	static const int min_exponent	= 0;
	static const int min_exponent10	= 0;
	static const int max_exponent	= 0;
	static const int max_expontent10 = 0;

	static const bool has_infinity	= false;
	static const bool has_quiet_NAN	= false;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	inline static unsigned long infinity() { return 0; } 
	inline static unsigned long quiet_NaN() { return 0; } 
	inline static unsigned long signaling_NaN() { return 0; } 
	inline static unsigned long denorm_min() { return 0; } 

	static const bool is_iec559	= false;
	static const bool is_bounded	= true;
	static const bool is_modulo	= true;
	static const bool traps		= false;
	static const bool tinyness_before = false;

	static const float_round_style round_style = round_toward_zero;
};

//
// Floating point specializations.
//
class numeric_limits<float>
{
public:
	static const bool is_specialized = true;

	inline static float min() { return @FLT_MIN@; } // FLT_MIN
	inline static float max() { return @FLT_MAX@; } // FLT_MAX

	static const int digits		= @FLT_MANT_DIG@; // FLT_MANT_DIG
	static const int digits10	= @FLT_DIG@; // FLT_DIG

	static const bool is_signed 	= true;
	static const bool is_integer 	= false;
	static const bool is_exact 	= false;

	static const int radix 		= @FLT_RADIX@; // FLT_RADIX
	inline static float epsilon() { return @FLT_EPSILON@; } // FLT_EPSILON
	inline static float round_error() { return 0.5f; }

	static const int min_exponent	= @FLT_MIN_EXP@; // FLT_MIN_EXP
	static const int min_exponent10	= @FLT_MIN_10_EXP@; // FLT_MIN_10_EXP
	static const int max_exponent	= @FLT_MAX_EXP@; // FLT_MAX_EXP
	static const int max_expontent10 = @FLT_MAX_10_EXP@; // FLT_MAX_10_EXP

	static const bool has_infinity	= true;
	static const bool has_quiet_NAN	= true;
	static const bool has_signaling_NAN = true;
	static const bool has_denorm	= false;

	inline static float infinity();
	inline static float quiet_NaN();
	inline static float signaling_NaN();
	inline static float denorm_min() { return min(); }

	static const bool is_iec559	= true;
	static const bool is_bounded	= true;
	static const bool is_modulo	= false;
	static const bool traps		= true;
	static const bool tinyness_before = true;

	static const float_round_style round_style = round_to_nearest;
};

inline float numeric_limits<float>::infinity()
{
	unsigned val = 0x7f800000;
	return *(float*)(&val);
} 

inline float numeric_limits<float>::quiet_NaN()
{
	unsigned val = 0x7fc00000;
	return *(float*)(&val);
} 

inline float numeric_limits<float>::signaling_NaN()
{
	unsigned val = 0x7fffffff;
	return *(float*)(&val);
} 

class numeric_limits<double>
{
public:
	static const bool is_specialized = true;

	inline static double min() { return @DBL_MIN@; } // DBL_MIN
	inline static double max() { return @DBL_MAX@; } // DBL_MAX

	static const int digits		= @DBL_MANT_DIG@; // DBL_MANT_DIG
	static const int digits10	= @DBL_DIG@; // DBL_DIG

	static const bool is_signed 	= true;
	static const bool is_integer 	= false;
	static const bool is_exact 	= false;

	static const int radix 		= @FLT_RADIX@; // FLT_RADIX
	inline static double epsilon() { return @DBL_EPSILON@; } // DBL_EPSILON
	inline static double round_error() { return 0.5F; }

	static const int min_exponent	= @DBL_MIN_EXP@; // DBL_MIN_EXP
	static const int min_exponent10	= @DBL_MIN_10_EXP@; // DBL_MIN_10_EXP
	static const int max_exponent	= @DBL_MAX_EXP@; // DBL_MAX_EXP
	static const int max_expontent10 = @DBL_MAX_10_EXP@; // DBL_MAX_10_EXP

	static const bool has_infinity	= true;
	static const bool has_quiet_NAN	= true;
	static const bool has_signaling_NAN = true;
	static const bool has_denorm	= false;

	inline static double infinity();
	inline static double quiet_NaN();
	inline static double signaling_NaN();
	inline static double denorm_min() { return min(); } 

	static const bool is_iec559	= true;
	static const bool is_bounded	= true;
	static const bool is_modulo	= false;
	static const bool traps		= true;
	static const bool tinyness_before = true;

	static const float_round_style round_style = round_to_nearest;
};

inline double numeric_limits<double>::infinity()
{
	return (double)numeric_limits<float>::infinity();
} 

inline double numeric_limits<double>::quiet_NaN()
{
	return (double)numeric_limits<float>::quiet_NaN();
} 

inline double numeric_limits<double>::signaling_NaN()
{
	return (double)numeric_limits<float>::signaling_NaN();
} 

class numeric_limits<long double>
{
public:
	static const bool is_specialized = true;

	inline static long double min() { return @LDBL_MIN@; } // LDBL_MIN
	inline static long double max() { return @LDBL_MAX@; } // LDBL_MAX

	static const int digits		= @LDBL_MANT_DIG@; // LDBL_MANT_DIG
	static const int digits10	= @LDBL_DIG@; // LDBL_DIG

	static const bool is_signed 	= true;
	static const bool is_integer 	= false;
	static const bool is_exact 	= false;

	static const int radix 		= @FLT_RADIX@; // FLT_RADIX
	inline static long double epsilon() { return @LDBL_EPSILON@; } // LDBL_EPSILON
	inline static long double round_error() { return 0.5L; }

	static const int min_exponent	= @LDBL_MIN_EXP@; // LDBL_MIN_EXP
	static const int min_exponent10	= @LDBL_MIN_10_EXP@; // LDBL_MIN_10_EXP
	static const int max_exponent	= @LDBL_MAX_EXP@; // LDBL_MAX_EXP
	static const int max_expontent10 = @LDBL_MAX_10_EXP@; // LDBL_MAX_10_EXP

	static const bool has_infinity	= true;
	static const bool has_quiet_NAN	= true;
	static const bool has_signaling_NAN = false;
	static const bool has_denorm	= false;

	static long double infinity();
	static long double quiet_NaN();
	static long double signaling_NaN();
	inline static long double denorm_min() { return min(); } 

	static const bool is_iec559	= true;
	static const bool is_bounded	= true;
	static const bool is_modulo	= false;
	static const bool traps		= true;
	static const bool tinyness_before = true;

	static const float_round_style round_style = round_to_nearest;
};

inline long double numeric_limits<long double>::infinity()
{
	return (long double)numeric_limits<float>::infinity();
} 

inline long double numeric_limits<long double>::quiet_NaN()
{
	return (long double)numeric_limits<float>::quiet_NaN();
} 

inline long double numeric_limits<long double>::signaling_NaN()
{
	return (long double)numeric_limits<float>::signaling_NaN();
} 

#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]