Skip to content

Instantly share code, notes, and snippets.

@valentyn-zaitsev
Created November 25, 2017 11:56
Show Gist options
  • Save valentyn-zaitsev/e69cbab0ea3a606711d0d433929af70d to your computer and use it in GitHub Desktop.
Save valentyn-zaitsev/e69cbab0ea3a606711d0d433929af70d to your computer and use it in GitHub Desktop.
Byte array to Float
void byteArrayToFloat(uint16_t length){//длина массива (если значений несколько*)
union
{
uint32_t j;
float f;
} u;
for (int i=0;i<length;i+=4){//*
u.j = array[i]<<24 | array[i+1]<<16 | array[i+2]<<8 | array[i+3];
printf("%.2f\n", u.f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment