Convert IEEE float hex to decimal?

后端 未结 4 1821
一整个雨季
一整个雨季 2021-01-15 13:35

IF I have a IEEE float hex 42F6E979, how do I convert it to decimal? I believe the decimal representation is = 123.456001

4条回答
  •  旧巷少年郎
    2021-01-15 14:09

    I'll do this in C, because you haven't provided a language.

    char hex[];
    int *ptr;
    for(int i = 0; i < 8; ++i)
    {
       &ptr += toNumber(hex[i]) << (i * 4);
    }
    
    float *value = (float*)ptr;
    

    I'll leave it up to the OP to write the toNumber function.

提交回复
热议问题