Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to control big numbers in QML like (-715827883)
Shubham Gupta last edited by
I have a variable like val=1
I have applied certain condition.
When the condition is true then val is multiplied by 3.
like 3, 9, 27, 81, 243..........
but after a long loop it shows like -715827883 value.
I want my result like,
When i start to execute my loop revesely
then val/3 is executed and at the end it will give 1.
But now its giving 0.
Variables in your computer have a limit - if you go over that limit, the value overflows, and the CPU will think that it is the at the lowest limit, instead of the highest.
This is not a QML thing, this is not a C++ thing - that is how computers work. You can read more about this here: https://en.wikipedia.org/wiki/Integer_overflow
To prevent that situation from happening, you should guard your arithmetic operation - check if result does not exceed INT_MAX in C (more info).