[solved] Statement always null
i have a problem with a calculation. here's the code:
@double newpos = ev->x() / 90;@
for example ev->x() is returning '20', then newpos will be 0! its always 0!
i also tried this:
@double newpos = 20 / 90;@
and the result is still always 0!
i have no idea why... please help me!
Because you are dividing integers. If you want to have a floating point result, you need to cast to a floating point number before dividing:
double newPos = static_cast<double>(ev->x())/90.0;