[Development] Changing qreal to a float

Thiago Macieira thiago.macieira at intel.com
Wed Feb 15 09:26:31 CET 2012


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.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120215/14ea975b/attachment.sig>


More information about the Development mailing list