The code
outputsCode:cout << " max = " << max << endl;
The codeCode:max = inf
or specifically the codeCode:if( 3.14 == inf )
won't compile. How can I determine if max is equal to infinity?Code:if( max == inf )
Printable View
The code
outputsCode:cout << " max = " << max << endl;
The codeCode:max = inf
or specifically the codeCode:if( 3.14 == inf )
won't compile. How can I determine if max is equal to infinity?Code:if( max == inf )
What is inf originally defined as? and are you using float?
What's the exact error?
the numeric_limits<> class has a has_infinity member and an infinity() function
Quote:
Originally Posted by manutd
Code:Rfilt.cpp: In member function `void Cwn::bounds()':
Rfilt.cpp:299: error: `inf' undeclared (first use this function)
Rfilt.cpp:299: error: (Each undeclared identifier is reported only once for
each function it appears in.)
"inf" is the value of "max." Max is a double.Quote:
Originally Posted by IdioticCreation
SHow us your complete code.
I'll show you the member function.Quote:
Originally Posted by manutd
Code:void Cwn::bounds()
{
long i;
double max = 0.0, min = 0.0;
for ( i = 0; i < samp2; i++)
{
if ( max < array2[i] )
max = array2[i];
if ( min > array2[i] )
min = array2[i];
}
cout << "from bounds(): " << " max of array2 = " << max << endl;
cout << "from bounds(): " << " min of array2 = " << min << endl;
if( max == inf )
{
cout << "Error: Filter unstable. Try setting -qual to a higher value." << endl;
exit(0);
}
}
More. Attach a text file if needed.
>> the numeric_limits<> class has a has_infinity member and an infinity() function
http://www.tacc.utexas.edu/resources...r/num_5679.htm
Code:Example
//
// limits.cpp
//
#include <limits>
int main()
{
numeric_limits<float> float_info;
if (float_info.is_specialized && float_info.has_infinity)
{
// get value of infinity
float finfinity=float_info.infinity();
}
return 0;
}
You still didn't say what inf actually is. You say it is the value of max, but how is it declared/defined. There is no "inf" in C++, so if you are using it you have to define it yourself. Show the code where you do that.
Isn't it obvious? He doesn't declare it.
Use Tonto's suggestion to fix the problem.
>> Isn't it obvious? He doesn't declare it.
Obviously it is not declared in the posted code, but thetinman indicated that it was assigned to max, which you can assume he or she might think is being done elsewhere. There is a misunderstanding there that needs to be fixed before JaWiB's and Tonto's suggestions can be used.
He said "inf" was output to the console, so he wrote it into his code. "inf" is not globally defined, it is not a variable. You have to define it as being the maximum value yourself.