Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hello,
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! thanks!
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; @