我试图将qint16
(int16
)与double
投放到mydouble = (double) myInt16;
并获得
error: invalid cast from type 'qint16* {aka short int*}' to type 'double'
如何将int16
转换为double
?
答案 0 :(得分:2)
根据您显示的代码,您没有int
。你有一个指向int
的指针。取消引用它,如下:
// Assume src points to a short int
double mydbl = *src;
从整数到双精度的转换将是自动的,但您必须取消引用指针。
答案 1 :(得分:2)
从错误中,myInt16
是指向short int
的指针。所以只需使用:
double mydouble = *myInt16;
short int
会自动提升为双倍。