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]

numeric_limits


I think you got a version of that code with errors in it...so sorry...
=(
// written by Edward Carter for gcc/egcs

#ifndef NUMERIC_LIMITS_H
#define NUMERIC_LIMITS_H

#include <math.h>
#include <limits.h>

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() throw();
    static T max() throw();
    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 = 0;
    static T epsilon() throw();
    static T round_error() throw();

    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_quiet_NaN;
    static const bool has_signaling_NaN;
    static const bool has_denorm;
    static const bool has_denorm_loss;
    static T infinity() throw();
    static T quiet_NaN() throw();
    static T signaling_NaN() throw();
    static T denorm_min() throw();

    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<unsigned> {
public:
    static const bool is_specialized;
    static unsigned min() throw();
    static unsigned max() throw();
    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 = 0;
    static unsigned epsilon() throw();
    static unsigned round_error() throw();

    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_quiet_NaN;
    static const bool has_signaling_NaN;
    static const bool has_denorm;
    static const bool has_denorm_loss;
    static unsigned infinity() throw();
    static unsigned quiet_NaN() throw();
    static unsigned signaling_NaN() throw();
    static unsigned denorm_min() throw();

    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<int> {
public:
    static const bool is_specialized;
    static int min() throw();
    static int max() throw();
    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 = 0;
    static int epsilon() throw();
    static int round_error() throw();

    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_quiet_NaN;
    static const bool has_signaling_NaN;
    static const bool has_denorm;
    static const bool has_denorm_loss;
    static int infinity() throw();
    static int quiet_NaN() throw();
    static int signaling_NaN() throw();
    static int denorm_min() throw();

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

// data members of numeric_limits<T>
template<class T> const bool numeric_limits<T>::is_specialized = false;
template<class T> const int numeric_limits<T>::digits = 0;
template<class T> const int numeric_limits<T>::digits10 = 0;
template<class T> const bool numeric_limits<T>::is_signed = false;
template<class T> const bool numeric_limits<T>::is_integer = false;
template<class T> const bool numeric_limits<T>::is_exact = false;
template<class T> const int numeric_limits<T>::radix = 0;
template<class T> const int numeric_limits<T>::min_exponent = 0;
template<class T> const int numeric_limits<T>::min_exponent10 = 0;
template<class T> const int numeric_limits<T>::max_exponent = 0;
template<class T> const int numeric_limits<T>::max_exponent10 = 0;
template<class T> const bool numeric_limits<T>::has_infinity = false;
template<class T> const bool numeric_limits<T>::has_quiet_NaN = false;
template<class T> const bool numeric_limits<T>::has_signaling_NaN = false;
template<class T> const bool numeric_limits<T>::has_denorm = false;
template<class T> const bool numeric_limits<T>::has_denorm_loss = false;
template<class T> const bool numeric_limits<T>::is_iec559 = false;
template<class T> const bool numeric_limits<T>::is_bounded = false;
template<class T> const bool numeric_limits<T>::is_modulo = false;
template<class T> const bool numeric_limits<T>::traps = false;
template<class T> const bool numeric_limits<T>::tinyness_before = false;
template<class T> const float_round_style numeric_limits<T>::round_style
                                                               = round_toward_zero;

// member functions of numeric_limits<T>
template<class T> inline T numeric_limits<T>::min() throw()
{
    return T();
}

template<class T> inline T numeric_limits<T>::max() throw()
{
    return T();
}

template<class T> inline T numeric_limits<T>::epsilon() throw()
{
    return T();
}

template<class T> inline T numeric_limits<T>::round_error() throw()
{
    return T();
}

template<class T> inline T numeric_limits<T>::infinity() throw()
{
    return T();
}

template<class T> inline T numeric_limits<T>::quiet_NaN() throw()
{
    return T();
}

template<class T> inline T numeric_limits<T>::signaling_NaN() throw()
{
    return T();
}

template<class T> inline T numeric_limits<T>::denorm_min() throw()
{
    return T();
}

// data members of numeric_limits<unsigned>
const bool numeric_limits<unsigned>::is_specialized = true;
const int numeric_limits<unsigned>::digits = sizeof(unsigned) * CHAR_BIT;
const int numeric_limits<unsigned>::digits10 = 
                              int(numeric_limits<unsigned>::digits/(log(10)/log(2)));
const bool numeric_limits<unsigned>::is_signed = false;
const bool numeric_limits<unsigned>::is_integer = true;
const bool numeric_limits<unsigned>::is_exact = true;
const int numeric_limits<unsigned>::radix = 2;
const int numeric_limits<unsigned>::min_exponent = 0;
const int numeric_limits<unsigned>::min_exponent10 = 0;
const int numeric_limits<unsigned>::max_exponent = 0;
const int numeric_limits<unsigned>::max_exponent10 = 0;
const bool numeric_limits<unsigned>::has_infinity = false;
const bool numeric_limits<unsigned>::has_quiet_NaN = false;
const bool numeric_limits<unsigned>::has_signaling_NaN = false;
const bool numeric_limits<unsigned>::has_denorm = false;
const bool numeric_limits<unsigned>::has_denorm_loss = false;
const bool numeric_limits<unsigned>::is_iec559 = false;
const bool numeric_limits<unsigned>::is_bounded = true;
const bool numeric_limits<unsigned>::is_modulo = true;
const bool numeric_limits<unsigned>::traps = false;     // is this true or false?...
const bool numeric_limits<unsigned>::tinyness_before = false;
const float_round_style numeric_limits<unsigned>::round_style = round_toward_zero;

// member functions of numeric_limits<unsigned>
inline unsigned numeric_limits<unsigned>::min() throw()
{
    return 0;
}

inline unsigned numeric_limits<unsigned>::max() throw()
{
    return UINT_MAX;
}

inline unsigned numeric_limits<unsigned>::epsilon() throw()
{
    return 0;
}

inline unsigned numeric_limits<unsigned>::round_error() throw()
{
    return 0;
}

inline unsigned numeric_limits<unsigned>::infinity() throw()
{
    return 0;
}

inline unsigned numeric_limits<unsigned>::quiet_NaN() throw()
{
    return 0;
}

inline unsigned numeric_limits<unsigned>::signaling_NaN() throw()
{
    return 0;
}

inline unsigned numeric_limits<unsigned>::denorm_min() throw()
{
    return 0;
}

// data members of numeric_limits<int>
const bool numeric_limits<int>::is_specialized = true;
const int numeric_limits<int>::digits = sizeof(unsigned) * CHAR_BIT - 1;
const int numeric_limits<int>::digits10 = 
                               int(numeric_limits<int>::digits/(log(10)/log(2)));
const bool numeric_limits<int>::is_signed = true;
const bool numeric_limits<int>::is_integer = true;
const bool numeric_limits<int>::is_exact = true;
const int numeric_limits<int>::radix = 2;
const int numeric_limits<int>::min_exponent = 0;
const int numeric_limits<int>::min_exponent10 = 0;
const int numeric_limits<int>::max_exponent = 0;
const int numeric_limits<int>::max_exponent10 = 0;
const bool numeric_limits<int>::has_infinity = false;
const bool numeric_limits<int>::has_quiet_NaN = false;
const bool numeric_limits<int>::has_signaling_NaN = false;
const bool numeric_limits<int>::has_denorm = false;
const bool numeric_limits<int>::has_denorm_loss = false;
const bool numeric_limits<int>::is_iec559 = false;
const bool numeric_limits<int>::is_bounded = true;
const bool numeric_limits<int>::is_modulo = true;
const bool numeric_limits<int>::traps = false;     // is this true or false?...
const bool numeric_limits<int>::tinyness_before = false;
const float_round_style numeric_limits<int>::round_style = round_toward_zero;

// member functions of numeric_limits<int>
inline int numeric_limits<int>::min() throw()
{
    return INT_MIN;
}

inline int numeric_limits<int>::max() throw()
{
    return INT_MAX;
}

inline int numeric_limits<int>::epsilon() throw()
{
    return 0;
}

inline int numeric_limits<int>::round_error() throw()
{
    return 0;
}

inline int numeric_limits<int>::infinity() throw()
{
    return 0;
}

inline int numeric_limits<int>::quiet_NaN() throw()
{
    return 0;
}

inline int numeric_limits<int>::signaling_NaN() throw()
{
    return 0;
}

inline int numeric_limits<int>::denorm_min() throw()
{
    return 0;
}

#endif

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