PDA

View Full Version : very small qreal number



dreamer
24th June 2008, 10:02
How can i disable the exponential notation? for example, if i get the topleft corner(QPointF) of a QGraphicsrectitem i couldn't have this kind of result:

QPointF(-1.06581e-14,12); but QPointF(-0.000000000"...",12); where the x coordinate is truncated at the ith position.....

caduel
24th June 2008, 10:57
You did not tell us, how you want to output that stuff... we have to guess what your problem is.

Anyway, have a look at QTextStream::setRealNumberNotation

HTH

dreamer
24th June 2008, 11:03
I read and generate number with a QTextstream so i use this code to resolve the problem:


QTextStream out("some file");
out.setRealNumberPrecision ( 5 );


The default real number precision is '6' that put in some case, the exponential "e" notation........setting it on '5' it doesn't appear.......
Is it just a case or is there a reason??

caduel
24th June 2008, 11:33
A clear case of "read the docs".

The default for QTextStream::setRealNumberNotation is QTextStream::SmartNotation.
(Checked the source...)

TextStream::SmartNotation => Scientific or fixed-point notation, depending on which makes most sense (printf()'s %g flag).

So, the answer "why" your code behaves like it does is probably given by "man 2 printf".