mercredi 14 août 2019

Narrowing conversion from char to double

Why there is a warning "narrowing conversion from char to double"?

I know already that for const char there will be no warning. There are a lot of answers about that. But I would like to know, why for non-const char there is a "might-narrow" warning?

Is it possible that on some systems mantissa is not big to perfectly represent char?

int main() {
  char c{7};
  double a{c};
}

4:13: warning: narrowing conversion of 'c' from 'char' to 'double' inside { } [-Wnarrowing]

Aucun commentaire:

Enregistrer un commentaire