Skip to content

Instantly share code, notes, and snippets.

@yswallow
Last active March 24, 2023 02:05
Show Gist options
  • Select an option

  • Save yswallow/47140b260ab247f0681a991ea76dbc8a to your computer and use it in GitHub Desktop.

Select an option

Save yswallow/47140b260ab247f0681a991ea76dbc8a to your computer and use it in GitHub Desktop.
浮動小数点数のビット列を見る
#include <stdio.h>
#include <stdint.h>
typedef union {
float f;
uint32_t l;
} float_bits_t;
int main(void) {
float_bits_t num;
num.f = -0.75;
for(int8_t i=31; i>0; i--) {
printf( ( num.l & (1UL<<i) ) ? "1" : "0" );
}
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment