在 x86 32bit 上将 8 字节内存转换为双数的算法是什么? [英] What's the algorithm to translate 8 byte memory into a double number on x86 32bit?

查看:20
本文介绍了在 x86 32bit 上将 8 字节内存转换为双数的算法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我在 32 位 Linux 上反汇编了一些代码,在应该存在 double 的 Rodata 部分,我找到了这 8 个字节:

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

原来的双数是10.0

谁能告诉我如何将这 8 个字节转换为双字节?

Could anyone tell me how to transform this 8 bytes into double?

推荐答案

将字节放入缓冲区,并要求 C 将内存解释为 double.

Put the bytes into a buffer and ask C to interpret the memory as a double.

#include <stdio.h>  

int main(){
    char* foo = "x00x00x00x00x00x00x24x40";
    double bar =*((double*) foo);
    printf("%f
", bar);
}

输出:

10.000000

这篇关于在 x86 32bit 上将 8 字节内存转换为双数的算法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆