static_assert(sizeof(unsigned) == 4, ":(");
static_assert(sizeof(double) == 8 ,":(");
unsigned u{42};
double x{u};
g++ 4.7.1 complains about this code:
warning: narrowing conversion of 'u' from 'unsigned int' to 'double' inside { }
Why is this a narrowing conversion? Isn't every unsigned
perfectly representable as a double
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…