Last active
March 24, 2023 02:05
-
-
Save yswallow/47140b260ab247f0681a991ea76dbc8a to your computer and use it in GitHub Desktop.
浮動小数点数のビット列を見る
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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