Saturday 15 January 2011

c++ - expressions doesn't return float value -



c++ - expressions doesn't return float value -

this question has reply here:

dividing 1/n returns 0.0 2 answers

when seek calculate expression, integer result, it's like:

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

the output in console 0.

in c/c++, integer division:

5/12

what want floating point division:

5.0/12.0

please note has absolutely nothing glut or opengl.

c++

No comments:

Post a Comment