Fwd: Re: qreal is float

Willy Gardiol willy at gardiol.org
Fri Nov 25 08:43:28 UTC 2011


I did not forwarded this on this list.

-------- Original Message --------
Subject: Re: qreal is float
Date: Fri, 25 Nov 2011 10:41:33 +0200
 From: Willy Gardiol <willy at gardiol.org>
To: <android-qt at googlegroups.com>
Reply-To: android-qt at googlegroups.com


Ok, i need to say my word on this.

I have been struggling with qreal a long time on Symbian. I have a gps 
tracking app and i need to use qtransform and do some floating point 
calculations.

On Symbian qreal == float, due to the fact that on the ARM cpus used by 
Nokia float is hardware and double is software emulated. I can tell you 
that there is a huge difference in speed. So i guess this would be also 
on Android, but probably given the vast differences in hardware maybe 
not all terminals would be affected in the same way, so if you test it 
on high-end cpu you dont see much difference.

This said, i would be VERY carefull in just doing some tests and then 
taking a decision. In fact, despite the fact i would love to have qreal 
== double and get rid of the so many ugly optiomizations i had to do to 
get the right precision in my code, it would piss me off immensly if 
speed would get worse on lower end CPUs because they dont implement 
double in hardware.

As a side note please rememebr that most of QtGui code internally uses 
qreals, so this choice would be impacting almost all the QPainter code, 
QRectF, QPOintF, QTransform, QMatrix and so on.

I actually had to copy the QTrasform code and make a double-only 
version of it to make sure some code executes with maximum precision. 
This said, it so slow on Nokia (5800xm, C6-01, C7, X7-00 at least) that 
i am only using it for one-time initialization code, for in-the-loop 
stuff realtime code you have to rely on floats.

So please be carefull on this decision.


Il 25.11.2011 08:14 BogDan Vatra ha scritto:
> Alpha 4 will be our last chance to make this change, because as I 
> said
> this change will break the ABI. Ill try this weekend to run qt
> benchmarks to see if the performance is the same, then we have to
> decide what should we do.
>
> Cheers,
> BogDan.
>
> Sent from my HTC Desire HD.
>
> ----- Reply message -----
> From: "Marco Bernasocchi"
> To:
> Subject: qreal is float
> Date: Fri, Nov 25, 2011 00:13
>
> Nope, the compilation would fail due to wrong method argument types
> expecting double and getting float.
>
> On 11/24/2011 11:09 PM, mingw android wrote:
>> Hi marco, was performance of doubles the problem? Can you give more
> details?
>>
>> On Nov 24, 2011 10:07 PM, "Marco Bernasocchi"  > wrote:
>>
>> It was a problem for me :) ended ip using some IFDEF like here [0]
>>
>> Ciao Marco
>> [0]
>>
> 
> https://github.com/__mbernasocchi/qgis-android/__blob/master/patches/qreal.__patch
>>
>>
>>
>>
>> On 11/24/2011 09:27 PM, qtnext wrote:
>>
>> Hi
>>
>> thanks for the link ... for me its not a problem, but It can be
>> important to add this information in a FAQ.
>>
>>
>> Le 24/11/2011 20:33, BogDan Vatra a écrit :
>>
>> Hi,
>>
>> I open a discussion about it here
>>
> 
> http://mail.kde.org/pipermail/__necessitas-devel/2011-__November/000678.html
>>
>> , keep an eye on that thread to see our decision.
>>
>> Thanks.
>>
>> Cheers,
>> BogDan.
>>
>>
>> 2011/11/15 qtnext:
>>
>> Hi,
>>
>> I have some strange troubles porting my apps ... And
>> after search I have
>> finded that qreal is a float in android (and double on
>> desktop).
>> Would be better to have qreal as double regarding this
>> article :
>>
> 
> http://developer.android.com/__guide/practices/design/__performance.html#avoidfloat
>>
>>
>>
>> Use Floating-Point Judiciously
>>
>> As a rule of thumb, floating-point is about 2x slower
>> than integer on
>> Android devices. This is true on a FPU-less, JIT-less G1
>> and a Nexus One
>> with an FPU and the JIT. (Of course, absolute speed
>> difference
>> between those
>> two devices is about 10x for arithmetic operations.)
>>
>> In speed terms, theres no difference between float and
>> double on the
>> more
>> modern hardware. Space-wise, double is 2x larger. As
>> with desktop
>> machines,
>> assuming space isnt an issue, you should prefer double
>> to float.
>>
>> Also, even for integers, some chips have hardware
>> multiply but lack
>> hardware
>> divide. In such cases, integer division and modulus
>> operations are
>> performed
>> in software — something to think about if youre
>> designing a hash
>> table or
>> doing lots of math.
>>
>>
>>
>>
>>
>> --
>> Marco Bernasocchi
>> www.opengis.ch
>>

-- 
Willy Gardiol
willy at gardiol.org
www.gardiol.org
www.trackaway.org -> Track YOUR way the way you want!

-- 
Willy Gardiol
willy at gardiol.org
www.gardiol.org
www.trackaway.org -> Track YOUR way the way you want!


More information about the Necessitas-devel mailing list