[Interest] Byte Swapping float and double

Constantin Makshin cmakshin at gmail.com
Sat Sep 7 23:28:11 CEST 2013


In this case such casting must be done only through pointers, otherwise
you'll just round the floating point number to some (direction dependens on
the system and its configuration) integer.
On Sep 8, 2013 12:22 AM, "Ilya Diallo" <ilya.diallo at gmail.com> wrote:

> Casting to qint32/qin64 (twice for 128 bits floats) and then using qToBigEndian
> ?
>
> 2013/9/7 Michael Jackson <imikejackson at gmail.com>
>
>> I'll plat the naive one here. What is the proper Qt API to byte swap a
>> float or double? create a union? or some other such trick like that?
>>
>> Thanks
>> Mike Jackson
>>
>> On Sep 7, 2013, at 2:29 PM, Etienne Sandré-Chardonnal <
>> etienne.sandre at m4x.org> wrote:
>>
>> > To be a little be more verbose, here is what the doc says for these
>> functions:
>> >
>> > Note: Template type T can either be a qint16, qint32 or qint64. Other
>> types of integers, e.g., qlong, are not applicable.
>> >
>> >
>> > 2013/9/7 Thiago Macieira <thiago.macieira at intel.com>
>> > On sábado, 7 de setembro de 2013 12:24:26, Michael Jackson wrote:
>> > > I have some code that needs to convert from the system to Big Endian
>> byte
>> > > order. All my integers work just fine but I am getting linker errors
>> when
>> > > trying to byte swap floats and doubles.
>> > >
>> > > I have #include <QtCore/QtEndian>
>> > >
>> > > and I have a templates function like this:
>> > >
>> > > template<typename T>
>> > > void foo(T value)
>> > > {
>> > >   value = qToBigEndian(value);
>> > >    .. does something with that data.
>> > > }
>> > >
>> >
>> > > What am I missing?
>> >
>> > Nothing. Those functions don't exist.
>> >
>> > --
>> > Thiago Macieira - thiago.macieira (AT) intel.com
>> >   Software Architect - Intel Open Source Technology Center
>> >
>> > _______________________________________________
>> > Interest mailing list
>> > Interest at qt-project.org
>> > http://lists.qt-project.org/mailman/listinfo/interest
>> >
>> >
>> > _______________________________________________
>> > Interest mailing list
>> > Interest at qt-project.org
>> > http://lists.qt-project.org/mailman/listinfo/interest
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130908/d749ecc9/attachment.html>


More information about the Interest mailing list