I have a class reading csv file containing numerical records with no more than two digits after the decimal point.
int ReadCellWithFloat(int cellNumber, int multiplier) throw (FSByFieldException)
{
GoToCell( cellNumber );
float number;
FileStream >> number;
std::cout << "what we've got: " << number;
if ( !FileStream.good() )
{
throw BuildException( FSByFieldException::NOT_FLOAT );
}
while ( multiplier-- )
{
number *= 10;
}
std::cout << ' ' << number << ' ' << (int) number << std::endl;
PassCell(); // here meaning pass comma separator
return (int) number;
}
For a cell containing float "8.49" the output yields:
what we've got: 8.49 849 848
Why 849 turns to 848 on casting to integer and how to fix it?