Double from long bits

前端 未结 3 1633
名媛妹妹
名媛妹妹 2021-01-02 23:17

I have an unsigned long long (or uint64_t) value and want to convert it to a double. The double shall have the same bit pattern as the

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 23:59

    The following uses a void pointer.

    unsigned long long bits = 1ULL;
    void* tempPtr=(void*)&bits;
    double result = *(double*)tempPtr;
    

提交回复
热议问题