crest
crest copied to clipboard
Question about kMinValue array
Hello, I have been modified yicies_solver for my term project.
I found that kMinValue[0](Minimum value of U_CHAR) does not give me correct value(0)
for(size_t i = 0 ; i < 1 ; ++i)
{
fprintf(stdout, "\tkMinValue[%u, %s]: %lld\n", i, type_names[i], kMinValue[i]);
fprintf(stdout, "\tkMaxValue[%u, %s]: %lld\n", i, type_names[i], kMaxValue[i]);
}
from above codes,
I saw the result live below
I know that kMaxValue is initialized at basic_types.cc as numeric_limits
kMinValue[0, U_CHAR]: 154468404
kMaxValue[0, U_CHAR]: 255
Thanks.
If you are printing the value make sure you use it converted to an integer. This is because by default, the C++ i/o streams convert 8 bit integer values to their ASCII counterpart which can cause some problems, that can be seen with this:
#include <iostream>
#include <limits>
#include <cassert>
using namespace std;
using std::numeric_limits;
int main(){
cout << numeric_limits<unsigned char>::min() << endl;
cout << (int)numeric_limits<unsigned char>::min() << endl;
return 0;
}
In this case the first print returns \00 and the second print returns the correct value: 0.