Re: [Interest] Byte Swapping float and double

2013-09-07 Thread Thiago Macieira
On sábado, 7 de setembro de 2013 15:41:37, Michael Jackson wrote: > 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? memcpy to a char buffer, byte swap. DO NOT reload the swapped float or double into a va

Re: [Interest] Byte Swapping float and double

2013-09-07 Thread Constantin Makshin
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" wrote: > Casting to qint32/qin64 (twice for 128 bits floats) and th

Re: [Interest] Byte Swapping float and double

2013-09-07 Thread Ilya Diallo
Casting to qint32/qin64 (twice for 128 bits floats) and then using qToBigEndian ? 2013/9/7 Michael Jackson > 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,

Re: [Interest] Byte Swapping float and double

2013-09-07 Thread Michael Jackson
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 wrote: > To be a little be more verbose, here is what the doc says for these fu

Re: [Interest] Byte Swapping float and double

2013-09-07 Thread Etienne Sandré-Chardonnal
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 > On sábado, 7 de setembro de 2013 12:24:26, Michael Jackson wrote

Re: [Interest] Byte Swapping float and double

2013-09-07 Thread Thiago Macieira
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 > > and I have a

[Interest] Byte Swapping float and double

2013-09-07 Thread Michael Jackson
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 and I have a templates function like this: template void foo(T value) { value = qToBigE