qreal is float

136 views
Skip to first unread message

qtnext

unread,
Nov 14, 2011, 5:29:36 PM11/14/11
to andro...@googlegroups.com
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, there's no difference between float and double on the more modern hardware. Space-wise, double is 2x larger. As with desktop machines, assuming space isn't 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 you're designing a hash table or doing lots of math.



BogDan Vatra

unread,
Nov 24, 2011, 2:33:57 PM11/24/11
to andro...@googlegroups.com
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 <qtn...@gmail.com>:

qtnext

unread,
Nov 24, 2011, 3:27:28 PM11/24/11
to andro...@googlegroups.com
Hi

thanks for the link ... for me it's 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 :

>> in software � something to think about if you're designing a hash table or
>> doing lots of math.
>>
>>

Marco Bernasocchi

unread,
Nov 24, 2011, 5:07:07 PM11/24/11
to andro...@googlegroups.com
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


--
Marco Bernasocchi
www.opengis.ch

mingw android

unread,
Nov 24, 2011, 5:09:31 PM11/24/11
to andro...@googlegroups.com

Hi marco, was performance of doubles the problem? Can you give more details?

in software — something to think about if you're designing a hash

table or
doing lots of math.





--
Marco Bernasocchi
www.opengis.ch

Marco Bernasocchi

unread,
Nov 24, 2011, 5:13:32 PM11/24/11
to andro...@googlegroups.com
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" <ma...@bernawebdesign.ch

> <mailto:ma...@bernawebdesign.ch>> 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


> <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 it's 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


> <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<qtn...@gmail.com <mailto:qtn...@gmail.com>>:


>
> 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


> <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, there's no difference between float and
> double on the
> more
> modern hardware. Space-wise, double is 2x larger. As
> with desktop
> machines,
> assuming space isn't 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 you're


> designing a hash
> table or
> doing lots of math.
>
>
>
>
>
> --
> Marco Bernasocchi

> www.opengis.ch <http://www.opengis.ch>
>


--
Marco Bernasocchi
www.opengis.ch

BogDan Vatra

unread,
Nov 25, 2011, 1:14:18 AM11/25/11
to andro...@googlegroups.com
Alpha 4 will be our last chance to make this change, because as I said this change will break the ABI. I'll 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" <ma...@bernawebdesign.ch>
To: <andro...@googlegroups.com>
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" <ma...@bernawebdesign.ch
> <mailto:ma...@bernawebdesign.ch>> 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
>     <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 it's not a problem, but It can be
>         important to add this information in a FAQ.
>
>
>                 in software — something to think about if you're

Willy Gardiol

unread,
Nov 25, 2011, 3:41:33 AM11/25/11
to andro...@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
wi...@gardiol.org
www.gardiol.org
www.trackaway.org -> Track YOUR way the way you want!

Reply all
Reply to author
Forward
0 new messages