-1

when i try to calculate any expression, I always get an integer result, it's like:

float k= 5/12;
std::cout<< k<<std::endl;   

the output in the console is always 0.

Phyp
  • 3
  • 1
  • 4

1 Answers1

1

In C/C++, this is an integer division:

5/12

What you want is a floating point division:

5.0/12.0

Please note that this has absolutely nothing to do with GLUT or OpenGL.

MrEricSir
  • 8,044
  • 4
  • 30
  • 35
  • 1
    `5.0/12.0` is actually a `double` division. If you want to operate on values of type `float`, it would be `5.0f/12.0f`. – Reto Koradi Nov 07 '14 at 07:03