On sexta-feira, 8 de novembro de 2013 10:34:00, Andreas Aardal Hanssen wrote:
> On 08 Nov 2013, at 10:15, Yves Bailly <[email protected]> wrote:
> > Le 08/11/2013 10:05, Giuseppe D'Angelo a écrit :
> >> 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;
> 
> QDataStream stores your content in a portable binary format. Specifying the
> floating point precision makes it clear that real numbers, be them
> represented in floats or doubles in C++, are stored as floats or doubles in
> file.
> 
> If you want to store a float as a float, and then a double as a double, you
> need to change the precision of QDataStream in between calls. Plus, the
> code that reads the file must match the code that wrote the stream.

We could provide an iomanipulator like QTextStream and iostream:

        ds << qSetSinglePrecision << f << qSetDoublePrecision << d;

        ds >> qSetSinglePrecision >> f >> qSetDoublePrecision >> d;

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to