在x86 32位上将8字节内存转换为双精度的算法是什么? [英] What's the algorithm to translate 8 byte memory into a double number on x86 32bit?
本文介绍了在x86 32位上将8字节内存转换为双精度的算法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
00000000 00002440
原来的双数是10.0
任何人都可以告诉我如何将这8个字节转换为双精度?
解决方案
要求 C
将内存解释为双精度。
#include< ; stdio.h中>
$ b int main(){
char * foo =\x00\x00\x00\x00\x00\x00\x24\x40;
double bar = *((double *)foo);
printf(%f\\\
,bar);
$ b $ p $输出:
10.000000
So basically I disassemble some code on 32bit Linux and in the rodata section, where double should exist, I find these 8 bytes:
00000000 00002440
The original double number is 10.0
Could anyone tell me how to transform this 8 bytes into double?
解决方案 Put the bytes into a buffer and ask C
to interpret the memory as a double.
#include <stdio.h>
int main(){
char* foo = "\x00\x00\x00\x00\x00\x00\x24\x40";
double bar =*((double*) foo);
printf("%f\n", bar);
}
Output:
10.000000
这篇关于在x86 32位上将8字节内存转换为双精度的算法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文