I have a Number type variable that gets set to a Text type variable and displayed.
It is turning an INT into a STR.
I am rounding the INT variable to show two decimal places before setting it to the STR.
I am using 'round(N * 100) / 100' as mentioned.
For the most part it is doing this, but occasionally I will get 1 or 0 decimal places.
3.49, 4.5, 5.23, 5.75, 6, 6.23
I believe it is happening when a number is an exact 4.5 or 6 and not +/- a small bit.
Anybody know how to prevent this?
****************************************
I found the answer.
https://www.scirra.com/tutorials/678/in ... -functions
You basically have to do what was mentioned above.
You have to do Math for both sides of the decimal point.
zeropad(int(time/60% 60), 2) & ":" & zeropad(int(time%60), 2)
This one is for time, I didn't test it, I just copied it from above link, it did point me towards zeropad though.
This will always result in 00:00 format.
str(floor(TestVariable/1)) & "." & str(zeropad(round(TestVariable * 100)%100,2))
I did test this one. It is for a number value that isn't time.
This will always result in 0:00 format.
If you need 00:00 or another combination then zeropad should be used.
Round(), Zeropad(,) and Modulo
https://www.scirra.com/manual/126/system-expressions
https://www.scirra.com/manual/78/expressions