[Development] Weird offseting in QDataStream

Yves Bailly yves.bailly at sescoi.fr
Fri Nov 8 10:15:21 CET 2013


Le 08/11/2013 10:05, Giuseppe D'Angelo a écrit :
> On 8 November 2013 10:01, Yves Bailly <yves.bailly at sescoi.fr> wrote:
>>
>> As a float is 4 bytes, I would expect the second f.pos() to display "4"... but
>> it displays "8", as if QDataStream had moved 8 bytes ahead instead of just 4.
>> Needless to say, the read float is wrong...
>>
>> Am I missing something here, or is it a bug?
>
> See QDataStream::setFloatingPointPrecision. The default is double.

That's pretty strange... what if I want to read a float then a double? do I
have to switch between the two each time?
Does this means it's impossible to use code like this:
float f;
double d;
datastream >> f >> d;
?

-- 
      /- Yves Bailly - Software developer   -\
      \- Sescoi R&D  - http://www.sescoi.fr -/
"The possible is done. The impossible is being done. For miracles,
thanks to allow a little delay."



More information about the Development mailing list