public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* mostly complete numeric_limits<>
@ 1998-02-17  2:18 Peeter Joot
  1998-02-18 17:15 ` Oleg Krivosheev
  0 siblings, 1 reply; 5+ messages in thread
From: Peeter Joot @ 1998-02-17  2:18 UTC (permalink / raw)
  To: egcs; +Cc: carter, kriol, miljenko.cvjetko

Hello,

I noticed that a limits implementation was posted to this list.  About a month
back I did one up as well, but never posted it because some things weren't 
implemented (and some stuff is likely incorrect).  

Some of the fields/members are probably not correct, but I have made my best 
guesses.  Of particular concern are the NaNs: 

I really don't know what the difference between a signalling NaN and a 
quiet NaN is.  I took a guess that a signalling nan has all the mantissa 
bits set, and the quiet one has at least the high mantissa bit clear.  This 
is quite possibly totally incorrect.

The float denorm_min stuff may be wrong.  I followed the example in the C++
draft where numeric_limits<float>::has_denorm == false.

I also took the easy way out for double and long double infinity and NaNs, 
where I have just cast the float versions.  This is not likely the best 
way of doing things.

This file should be autogenerated (like float.h) so the namespace isn't 
polluted with everything from the included header files.  But until someone 
implements code to do that, ...

For the digits10 fields it is assumed that there are 8 bits to a char, int is 
32 bits, and a long is either 32 or 64 bits.

Anyways, I thought I would post this to this list for any comments and 
for possible use by anybody interested -- I am willing to do the work to 
clean this up for contribution, but need some feedback and review of what 
is done so far.

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

------------------------------------------------------------------------------
// limits
#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; }

	// these are wrong, but seem irrelevant
	static const int digits		= 1;
	static const int digits10	= 1;

	// this could be wrong, but seems irrelevant
	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;
};

#include <cfloat>
#include <climits>
#include <cwchar>
//
// Character specializations.
//
class numeric_limits<char>
{
public:
	static const bool is_specialized = true;

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

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

#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; }
	inline static signed char max() { return CHAR_MAX; }

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

	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; }

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

	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;
};

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

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

	static const int digits		= sizeof(wchar_t)*CHAR_BIT;
//	static const int 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;
};

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

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

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

	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; }

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

	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; }
	inline static int max() { return INT_MAX; }

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

	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; }
	inline static unsigned int max() { return INT_MAX; }

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

	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;

	inline static long min() { return LONG_MIN; }
	inline static long max() { return LONG_MAX; }

	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	= 9;
#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; }
	inline static unsigned long max() { return ULONG_MAX; }

	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	= 9;
#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;
};

#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
class numeric_limits<long long>
{
public:
	static const bool is_specialized = true;

	inline static long long min() { return LONG_LONG_MIN; }
	inline static long long max() { return LONG_LONG_MAX; }

	static const int digits		= sizeof(long long)*CHAR_BIT;
	static const int digits10	= 18;

	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 long epsilon() { return 0; }
	inline static long 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 long infinity() { return 0; } 
	inline static long long quiet_NaN() { return 0; } 
	inline static long long signaling_NaN() { return 0; } 
	inline static long 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 long>
{
public:
	static const bool is_specialized = true;

	inline static unsigned long long min() { return 0; }
	inline static unsigned long long max() { return ULONG_LONG_MAX; }

	static const int digits		= sizeof(unsigned long long)*CHAR_BIT;
	static const int digits10	= 19;

	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 long long epsilon() { return 0; }
	inline static unsigned long 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 long infinity() { return 0; } 
	inline static unsigned long long quiet_NaN() { return 0; } 
	inline static unsigned long long signaling_NaN() { return 0; } 
	inline static unsigned long 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;
};
#endif

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

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

	static const int digits		= FLT_MANT_DIG;
	static const int digits10	= 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;
	inline static float epsilon() { return FLT_EPSILON; }
	inline static float round_error() { return 0.5f; }

	static const int min_exponent	= FLT_MIN_EXP;
	static const int min_exponent10	= FLT_MIN_10_EXP;
	static const int max_exponent	= FLT_MAX_EXP;
	static const int max_expontent10 = 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; }
	inline static double max() { return DBL_MAX; }

	static const int digits		= DBL_MANT_DIG;
	static const int digits10	= 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;
	inline static double epsilon() { return DBL_EPSILON; }
	inline static double round_error() { return 0.5F; }

	static const int min_exponent	= DBL_MIN_EXP;
	static const int min_exponent10	= DBL_MIN_10_EXP;
	static const int max_exponent	= DBL_MAX_EXP;
	static const int max_expontent10 = 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; }
	inline static long double max() { return LDBL_MAX; }

	static const int digits		= LDBL_MANT_DIG;
	static const int digits10	= 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;
	inline static long double epsilon() { return LDBL_EPSILON; }
	inline static long double round_error() { return 0.5L; }

	static const int min_exponent	= LDBL_MIN_EXP;
	static const int min_exponent10	= LDBL_MIN_10_EXP;
	static const int max_exponent	= LDBL_MAX_EXP;
	static const int max_expontent10 = 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mostly complete numeric_limits<>
  1998-02-17  2:18 mostly complete numeric_limits<> Peeter Joot
@ 1998-02-18 17:15 ` Oleg Krivosheev
  1998-02-18 17:37   ` Joe Buck
  1998-02-18 23:56   ` Peeter Joot
  0 siblings, 2 replies; 5+ messages in thread
From: Oleg Krivosheev @ 1998-02-18 17:15 UTC (permalink / raw)
  To: peeter; +Cc: egcs, carter, miljenko.cvjetko, Edward Carter

Hi,

On Tue, 17 Feb 1998, Peeter Joot wrote:

> Hello,
> 
> I noticed that a limits implementation was posted to this list.  About a month
> back I did one up as well, but never posted it because some things weren't 
> implemented (and some stuff is likely incorrect).  
> 
> Some of the fields/members are probably not correct, but I have made my best 
> guesses.  Of particular concern are the NaNs: 
> 
> I really don't know what the difference between a signalling NaN and a 
> quiet NaN is.  I took a guess that a signalling nan has all the mantissa 
> bits set, and the quiet one has at least the high mantissa bit clear.  This 
> is quite possibly totally incorrect.
> 
> The float denorm_min stuff may be wrong.  I followed the example in the C++
> draft where numeric_limits<float>::has_denorm == false.
> 
> I also took the easy way out for double and long double infinity and NaNs, 
> where I have just cast the float versions.  This is not likely the best 
> way of doing things.

i was trying to make a point that numeric_limits contains
vital information about target architecture - therefore it
should be automatically generated after configure run.

We have to decide where num_limits generator will live
and what part of full header should be generated.

Also should generator itself be small C code or shell
script will be enough.

Without that the providing pieces of specialization for
char, short etc is, IMHO, a bit pointless.


regards

OK


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mostly complete numeric_limits<>
  1998-02-18 17:15 ` Oleg Krivosheev
@ 1998-02-18 17:37   ` Joe Buck
  1998-02-18 22:21     ` Jeffrey A Law
  1998-02-18 23:56   ` Peeter Joot
  1 sibling, 1 reply; 5+ messages in thread
From: Joe Buck @ 1998-02-18 17:37 UTC (permalink / raw)
  To: Oleg Krivosheev; +Cc: peeter, egcs, carter, miljenko.cvjetko

> We have to decide where num_limits generator will live
> and what part of full header should be generated.

I think that the process should look a lot like the "enquire"
program, which generates float.h for ANSI C by doing tests on
the machine.  (But there are problems with cross-compilation:
how is this handled by enquire?).

Another approach is just to extend enquire a bit to make the extra
information.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mostly complete numeric_limits<>
  1998-02-18 17:37   ` Joe Buck
@ 1998-02-18 22:21     ` Jeffrey A Law
  0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey A Law @ 1998-02-18 22:21 UTC (permalink / raw)
  To: Joe Buck; +Cc: Oleg Krivosheev, peeter, egcs, carter, miljenko.cvjetko

  In message < 199802190135.RAA10857@atrus.synopsys.com >you write:
  > I think that the process should look a lot like the "enquire"
  > program, which generates float.h for ANSI C by doing tests on
  > the machine.  (But there are problems with cross-compilation:
  > how is this handled by enquire?).
For cross compiles, the enquire issue is punted.  Instead of trying
to run enquire a suitable float.h is selected from the gcc/config
directory.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mostly complete numeric_limits<>
  1998-02-18 17:15 ` Oleg Krivosheev
  1998-02-18 17:37   ` Joe Buck
@ 1998-02-18 23:56   ` Peeter Joot
  1 sibling, 0 replies; 5+ messages in thread
From: Peeter Joot @ 1998-02-18 23:56 UTC (permalink / raw)
  To: Oleg Krivosheev; +Cc: egcs, carter, miljenko.cvjet

> i was trying to make a point that numeric_limits contains
> vital information about target architecture - therefore it
> should be automatically generated after configure run.

> Without that the providing pieces of specialization for
> char, short etc is, IMHO, a bit pointless.
 
I agree that it should be autogenerated, but what I have 
currently is mostly portable as it uses the appropriate 
constants from cfloat and climits rather than hard coded 
values.  I don't think it is pointless to provide the 
specializations in this fashion -- its just not a state 
that is ready for contribution to the compiler.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-02-18 23:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-17  2:18 mostly complete numeric_limits<> Peeter Joot
1998-02-18 17:15 ` Oleg Krivosheev
1998-02-18 17:37   ` Joe Buck
1998-02-18 22:21     ` Jeffrey A Law
1998-02-18 23:56   ` Peeter Joot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).