0

trying to convert uint16 to double ; I got some precision trouble :

    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

Is this an issue with received value msg.getBidPrice() ?

0 Answers0