Skip to content

Instantly share code, notes, and snippets.

@louqash
Last active March 23, 2023 11:47
Show Gist options
  • Save louqash/307ef6996ba91ed0e0813b4a9d260fcb to your computer and use it in GitHub Desktop.
Save louqash/307ef6996ba91ed0e0813b4a9d260fcb to your computer and use it in GitHub Desktop.
Gcc ignores cast to signed int16 and float ends up positive
#include <iostream>
#include <cstdint>
int main() {
uint8_t a = 0x80;
uint8_t b = 0x01;
float c = (float)(((int16_t)a << 8) | b);
std::cout << c << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment