How to convert integer to double implicitly?

int a{5},b{2},c{9};
double d = (double)a / (double)b + (double)c;

Or I can use static_cast. Either way is verbose, especially when the formula is long. Is there a better solution?

Leave a Comment