将uint转换为double c ++

时间:2018-04-04 12:59:16

标签: c++ type-conversion

尝试将uint16转换为double;我遇到了一些精确的麻烦:

    inline static double makePrice(uint16_t data)
    {
        return (double)data/100;
    }

    int priceOffset = -100;
    double const bidPrice = makePrice(msg.getBidPrice()+ priceOffset * 100);


Here the value with GDB :
    (gdb) p msg.getBidPrice()
    $8 = 17590
    (gdb) p  API::makePrice(msg.getBidPrice()+ priceOffset * 100)
    $9 = 175.90000000000001
    (gdb) p priceOffset
    $10 = 0
    (gdb) p msg.getBidPrice()/100.0
    $11 = 175.89999999999998

这是收到的值msg.getBidPrice()的问题吗?

0 个答案:

没有答案