[Development] Changing qreal to a float

lars.knoll at nokia.com lars.knoll at nokia.com
Wed Feb 15 13:33:18 CET 2012


On 2/15/12 12:53 PM, "ext andre.poenitz at nokia.com"
<andre.poenitz at nokia.com> wrote:

>
>> Sletta Gunnar (Nokia-MP/Oslo) wrote:
>>  - Using "double" is pure waste for a lot of use cases. QRectF,
>>QPointF, QPainter, QPolygonF,
>> OpenGL, QMouseEvent, QTouchEvent, to name a few. None of these  require
>>the precision 
>> offered by double precision floating  point.
>
>Whether having doubles in a QPolygonF or a QRectF is necessary depends on
>what you are doing with it. If you restrict it to the the current
>Qt-internal use cases, 'float' is possibly fine, if you use it for
>general coordinate handling in, say, GIS it is certainly not.
>
>> The only questionable use case is geolocation. We know for a fact that
>>floats have limitations
>> in this area and both Qt3D and QtLocation make use of QVector[2|3|4]D
>>and QMatrix4x4 which
>> will now be a float. However, this is no worse (for device) than it
>>already is, 
>
>It won't be worse in the _embedded_ case (and even there only for the
>embedded cases that did not use a custom build of Qt with hard-coded
>'double' for qreal). Right...
>
>I seem to remember  we had this kind of discussion in ~2006 already, and
>back then the resolution was to have "double" at least on the desktop
>side to cover the GIS cases. Sending someone to the wrong side of a 100m
>wide river just because the navigation system insisted on using single
>precision float seemed inacceptable at that time.

Just a small nitpick: You won't end up on the wrong side of the river. The
earth has a diameter of around 40000km. With 24 bits precision, you end up
with a jitter of just above 2m. You might get wet feet though ;-)

Cheers,
Lars

> 
>
>Anyway. It's probably better to go for any kind of uniformity. If that's
>single precision, it should be made clear  that QPolygonF/QRectF are not
>meant for applications needing "polygons" in general. Maybe one should
>consider adding some QPolygonD/QRectD/... later to get the functionality
>back. Until these exist, it might be worthwhile to keep the (then
>unconditional) typedef though, to allow easy creation of custom builds of
>Qt with double precision coordinates.
>
>Andre'
>_______________________________________________
>Development mailing list
>Development at qt-project.org
>http://lists.qt-project.org/mailman/listinfo/development




More information about the Development mailing list