小数値(32bit Float)から4バイトのバイナリを求めるツールです。
Revisión | 1 (tree) |
---|---|
Tiempo | 2014-06-01 22:39:03 |
Autor | xops-mikan |
(empty log message)
@@ -0,0 +1,28 @@ | ||
1 | +#include <stdio.h> | |
2 | +#include <windows.h> | |
3 | + | |
4 | +union ufloat { | |
5 | + float f; | |
6 | + unsigned u; | |
7 | +}; | |
8 | + | |
9 | +int main() | |
10 | +{ | |
11 | + ufloat u1; | |
12 | + float x; | |
13 | + | |
14 | + printf("数値を入力してください > "); | |
15 | + scanf("%f", &x); | |
16 | + u1.f = x; | |
17 | + | |
18 | + //printf("%X", u1.u); | |
19 | + printf("%02X ", (unsigned char)(u1.u&0x000000FF)); | |
20 | + printf("%02X ", (unsigned char)((u1.u&0x0000FF00) >> 8)); | |
21 | + printf("%02X ", (unsigned char)((u1.u&0x00FF0000) >> 16)); | |
22 | + printf("%02X ", (unsigned char)((u1.u&0xFF000000) >> 24)); | |
23 | + | |
24 | + printf("\n"); | |
25 | + system("pause"); | |
26 | + | |
27 | + return 0; | |
28 | +} | |
\ No newline at end of file |