Results 1 to 6 of 6

Thread: Use of numeric_limits class in the C++

  1. #1
    Join Date
    Dec 2009
    Posts
    26

    Use of numeric_limits class in the C++

    Hi Everyone, I am the student of the BSC. I had the C++ language in the syllabus. I had heard that the C++ language can be very easy to learn as compare to the other languages. But I can not know about the numeric_limits class in C++ language. So, I would like to know about the How can I use the numeric_limits class in C++ language. Can anyone has the answer for me then reply me!!
    Last edited by Garrick; 13-02-2010 at 05:48 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    The numeric_limits class

    Hello, I guess you can have the knowledge of the class in the C++ language. So, there can be no need to explain you about the class. The numeric_limits class can be specialized for each of the fundamental types, with it's set to the various values or with it's member's returning that can be defined the properties of that type can be compiles in the specific platform.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Use of numeric_limits class in the C++

    In the numeric_limits class, A specialization can be exists for each of the fundamental types as follows :
    long double, wchar_t, bool, unsigned char, short, char, int, unsigned short, long, signed char, unsigned int, unsigned long, double and float. These specializations of the numeric_limits class can define the particular values for the various static const members. All the specialization of the numeric_limits class can have is_specialized be defined as true.
    Last edited by Katty; 13-02-2010 at 05:47 PM.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    The numeric_limits

    The following program demonstrates you that how can you use the numeric_limits class in the C++ language :
    Code:
    #include <iostream>
    #include <limits>
    using namespace std;
    int main () 
    {
      cout << bolalpa;
      cout << "Mini value for int: " << numeric_limits<int>::min() << endl;
      cout << "Maxi value for int: " << numeric_limits<int>::max() << endl;
      cout << "int is signed: " << numeric_limits<int>::issigned << endl;
      cout << "Nonsign bits in int: " << numeric_limits<int>::digits << endl;
      cout << "int has infinity: " << numeric_limits<int>::hasinfinity << endl;
      return 0;
    }
    Output :
    Code:
    Mini value for int: -2147483648
    Maxi value for int: 2147483647
    int is signed: true
    Nonsign bits in int: 31
    int has infinity: false

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    numeric_limits class

    Code:
    namespace std 
    {
      template <class T>
      class numeric_limits 
    {
        public:
        static T min () throw();
        static T max () throw();
        static const int rdx ;
        static const int dgts ;
        static const int dgts10 ;
        static const bool issigned ;
        static const bool isinteger ;
        static const bool isexact ;
        static const bool trps ;
        static const bool ismodulo ;
        static const bool isbounded ;
        static T epsiln () throw();
        static T rounderror () throw();
        static const int minexponent10 ;
        static const int maxexponent10 ;
        static const int minexponent ;
        static const int maxexponent ;
        static const bool hasinfinity ;
        static const bool hasquietNaN ;
        static const bool hassignalingNaN ;
        static const bool isiec559 ;
        static const floatdenormstyle hasdenorm ;
        static const bool hasdenormloss;
        static const bool tinynessbefore ;
        static const floatroundstyle roundstyle ;
        static T denrmin () throw();
        static T infinty () throw();
        static T quietNaN () throw();
        static T signalingNaN () throw();
      };
      enum floatroundstyle 
    {
        roundindeterminate       = -1,
        roundtowardzero         =  0,
        roundtonearest          =  1,
        roundtowardinfinity     =  2,
        roundtowardneginfinity =  3
      };
      enum floatdenormstyle 
    {
        denormindeterminate      = -1,
        denormabsent             =  0,
        denormpresent            =  1
      };
    }

  6. #6
    Join Date
    Nov 2005
    Posts
    1,323

    Use of numeric_limits

    A numeric_limits class template can be used for representing the information about the types that can be of the type arithmetic. The following can be the syntax of the numeric_limits class :
    Code:
    #include <limits>
    namespace std {
      template <class T>
      class numeric_limits;
    }

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. What is the difference between Local class and global class in C++?
    By Dëfrim in forum Software Development
    Replies: 4
    Last Post: 03-01-2011, 10:44 PM
  3. Replies: 5
    Last Post: 12-02-2010, 06:23 PM
  4. Ultra solid drives:Imation M-Class and S-Class
    By Regina in forum Portable Devices
    Replies: 1
    Last Post: 03-04-2009, 10:34 AM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,002,487.71344 seconds with 17 queries