0

For some reason, when I try to print doubles between 0 and 1 out, they always evaluate to 0. For example, these all print 0:

double width_ratio = 180 / 360;
double height_ratio = 80 / 100;
std::cout << 180 / 360 << std::endl;
std::cout << width_ratio << std::endl;
std::cout << height_ratio << std::endl;

Actual output:

0
0
0

My expected/desired output:

0.5
0.5
0.8

How am I supposed to fix this?

HughJass24
  • 39
  • 1
  • 4

0 Answers0