www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/19/11:05:29

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: alt.comp.lang.learn.c-c++,comp.os.msdos.djgpp
Subject: Re: Where is <limits>?
Date: Wed, 19 May 1999 02:25:42 -0400
References: <5xi03.345$UW4 DOT 518 AT news DOT get2net DOT dk>
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
X-ELN-Date: 19 May 1999 06:24:30 GMT
X-ELN-Insert-Date: Tue May 18 23:35:18 1999
Organization: Nocturnal Aviation
Lines: 92
Mime-Version: 1.0
NNTP-Posting-Host: dialup-209.246.82.187.newyork2.level3.net
Message-ID: <37425966.26045697@earthlink.net>
X-Mailer: Mozilla 4.51 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

David List wrote:
> 
> Iīm learning from Ivor Hortonīs "Beginning C++" and using djgpp with RHIDE. When I try out Mr. Hortonīs directions for getting the minimum and maximum size of types, I get an error message telling me: Error: limits: No such file or directory (ENOENI). Could someone please tell me what the reason for this could be? Here is the code that gives me this problem. It is almost the same as in Mr. Hortonīs 'Program 3.3':
> 
> #include <iostream>
> #include <limits>
> using namespace std;

The problem is that djgpp does not yet have the new <limits> header.  The
closest you can come right now is to use the C++ <climits> version of the C
<limits.h> header and  C++ <cfloat> version of the C <float.h> header.
<limits> specifies a much larger number of values than do <climits> and
<cfloat>, such as numeric_limits<char>::is_signed,
numeric_limits<float>::has_infinity and so on.  The appropriate <climits> and
<cfloat> macros are shown interspersed with you code below.


#include <climits>	// the approximate workaround for 
#include <cfloat>       // the missing <limits> header

> 
> int main()
>  {
>   cout << "The data type char ranges from"
>        << numeric_limits<char>::min()
>        << " to "
>        << numeric_limits<char>::max()

This will need to be
         << CHAR_MAX

>        << endl;
>   cout << "The data type short ranges from"
>        << numeric_limits<short>::min()
>        << " to "
>        << numeric_limits<short>::max()

This will need to be
         << SHRT_MIN << " to " << SHRT_MAX

>        << endl;
>   cout << "The data type int ranges from"
>        << numeric_limits<int>::min()
>        << " to "
>        << numeric_limits<int>::max()

         << INT_MIN << " to " << INT_MAX

>        << endl;
>  cout << "The data type long ranges from"
>        << numeric_limits<long>::min()
>        << " to "
>        << numeric_limits<long>::max()

         << LONG_MIN << " to " << LONG_MAX

>        << endl;
>  cout << "The data type float ranges from"
>        << numeric_limits<float>::min()
>        << " to "
>        << numeric_limits<float>::max()

         << FLT_MIN << " to " << FLT_MAX
            // Note that these are both poitive values

>        << endl;
>  cout << "The data type double ranges from"
>        << numeric_limits<double>::min()
>        << " to "
>        << numeric_limits<double>::max()

         << DBL_MIN << " to " << DBL_MAX

>        << endl;
>  cout << "The data type long double ranges from"
>        << numeric_limits<long double>::min()
>        << " to "
>        << numeric_limits<long double>::max()


         << LDBL_MIN << " to " << LDBL_MAX

>        << endl;
> 
>  return 0;
> }



-- 
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive

- Raw text -


  webmaster     delorie software   privacy  
  Copyright Đ 2019   by DJ Delorie     Updated Jul 2019