Absolutely !!! Copying memory 3 times is not efficient already. :) Thanks
Martin.
I just need to get 2 or a few skeleton segments for a contemporary dance
performance, and this way, I will solve my problem temporarily. Xsens may
not be a widely used system, but it works great. I think it deserves
On Sat, Apr 6, 2019 at 10:54 AM Arda Eden wrote:
> With this method, I got the compiler warning about breaking the strict
> aliasing rule:
> uint8_t bytes[4] = {12, 34, 56, 78};
> float f = *(float*)bytes;
>
> Yes, modern c doesn't like type punning.
> This is my code, and for now, it is
With this method, I got the compiler warning about breaking the strict
aliasing rule:
uint8_t bytes[4] = {12, 34, 56, 78};
float f = *(float*)bytes;
This is my code, and for now, it is working properly. But I am not sure if
this is an efficient way or not.
typedef struct _xsensparse
{
On Sat, Apr 6, 2019 at 10:06 AM Christof Ressi
wrote:
> While type punning through unions is allowed in C, the only way which
> works in both C and C++ (without breaking the strict aliasing rule) is
> using memcpy. In such case, the call to memcpy will completely optimized
> away by every decent
While type punning through unions is allowed in C, the only way which works in
both C and C++ (without breaking the strict aliasing rule) is using memcpy. In
such case, the call to memcpy will completely optimized away by every decent
compiler.
> Gesendet: Samstag, 06. April 2019 um 11:28 Uhr
On Sat, 2019-04-06 at 11:28 +0200, cyrille henry wrote:
>
>
> An other solution is to use bitwise operator :
>
> my_float = (byte1 << 24) & (byte2 << 16) & (byte3 << 8) & byte4;
From what I understand, the result is not a 32 bit floating point
number, but a 32 bit unsigned int (assuming that
hello,
I think a better way (that did not need to copy the data) is to use a union :
i.e. 2 different type can be declared in the same memory space.
something like :
// union type definition
union int_and_float {
int8_t my_int[4];
float my_float;
};
int_and_float my_int_and_float; //