小编owe*_*inh的帖子

我试图访问浮点数中的单个字节,我得到意想不到的结果

所以我到目前为止:

#include <iostream>
#include <string>
#include <typeinfo>

using namespace std;

int main ()
{
    float f = 3.45;           // just an example fp#
    char* ptr = (char*)&f;    // a character pointer to the first byte of the fp#?

    cout << int(ptr[0]) << endl; // these lines are just to see if I get what I 
    cout << int(ptr[1]) << endl; // am looking for... I want ints that I can 
    cout << int(ptr[2]) << endl; // otherwise manipulate.
    cout << …
Run Code Online (Sandbox Code Playgroud)

c++ floating-point

0
推荐指数
1
解决办法
102
查看次数

标签 统计

c++ ×1

floating-point ×1