[Development] Changing qreal to a float

lars.knoll at nokia.com lars.knoll at nokia.com
Wed Feb 15 09:49:31 CET 2012


On 2/15/12 9:26 AM, "ext Thiago Macieira" <thiago.macieira at intel.com>
wrote:

>On quarta-feira, 15 de fevereiro de 2012 07.38.44,
>gunnar.sletta at nokia.com
>wrote:
>> Our initial idea was to change "qreal" to "double" to avoid any
>>potential
>> regression but the impact on size combined with the fact that the added
>> precision is almost never needed changed our minds
>> (https://bugreports.qt-project.org/browse/QTBUG-23758)
>
>There is one reason for choosing double though: it can store any 32-bit
>integer without loss of precision. So doubles can be used to pass around
>pixel 
>coordinates that are 32-bit integers. That's the reason Wayland chose to
>use 
>it for all coordinates.
>
>Float has 24 bits of mantissa precision, which is enough for
>16777216x16777216 
>pixels. Probably good enough I'd say.
>
>I think the most important thing is to unify the definition. Every time I
>met 
>someone from Canonical, they asked me about it because trying to build Qt-
>based software on ARM revealed lots of float-double mistakes.
>
>Note: changing qreal to float is source-incompatible and requires manual
>fixups 
>where it breaks. But it's not silent.

I don't think it'll break too many places though, so I'm not too worried
about the change.

Choosing float has my vote, as it'll use a lot less memory and is the
right thing in the common case. It also directly maps to OpenGL types.
Let's rather use double explicitly where needed.

Cheers,
Lars




More information about the Development mailing list