What's the algorithm to translate 8 byte memory into a double number on x86 32bit?

别说谁变了你拦得住时间么 提交于 2019-12-13 02:54:35

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/23098681/whats-the-algorithm-to-translate-8-byte-memory-into-a-double-number-on-x86-32bi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!