Im trying to read data from this file:
Which contains both ascii text and float numbers stored in binary. I'm trying to read it by doing the following:
QTextStream in(file);
QString line;
line = in.readLine();
while (!line.startsWith(QString("element vertex"))) {
line = in.readLine();
}
point_count = line.split(QString(" ")).last().toInt();
qDebug() << "PC: " << point_count;
while (line != "end_header") {
line = in.readLine();
}
QDataStream* stream = new QDataStream(file);
stream->skipRawData(in.pos());
stream->setFloatingPointPrecision(QDataStream::SinglePrecision);
float number;
(*stream) >> number;
qDebug() << "Float: " << number;
But I read -1.98117e 13, which I guess it is wrong, what am I doing wrong?
CodePudding user response:
The default byte order for QDataStream is big endian; change it to little endian:
stream->setByteOrder(QDataStream::LittleEndian)