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).
I'm working with decimal number, and this is my code:
double fraction = 3/4; qDebug() << fraction
Instead of 0.75, QtCreator display 0. Is a QtCreator bug, or my procedure is wrong? If so, you could tell me which is the right one?
Thanks in advance
Hi, Try it with 3/4.0. -Michael.
You are dividing two integers. Integer-Division of a value by a larger value results to zero by definition in C++. As long as you are not making one value a double there will be no implicit cast in C++ before assigning the result to the double.