I was checking the below tutorial Decimals in a float and here is my workaround:
Create the global variables:
tNumber (text variable)
fNumber (float variable)
Later set tNumber = left( str(fNumber), find( str(fNumber), ".")+3)
fNumber = 5003.563373
tNumber = 5003.56
fNumber = 78.30048573
tNumber = 78.30 <-- last digit stays 0
So what does the argument do?
left(text, number) takes the text and returns number of characters
The number of characters is set by find-function, which looks for the "." and adds the "." plus two additional characters (therefore 3 has to be added)
The dot "." is on position 4, but left()-function will return 5003
Therefore we need to add 3 and this gives 5003.56 (7 characters in total).
If variable *numberOfDecimals* (int) is required, simply define this variable.
The formula is now:
set tNumber = left( str(fNumber), find( str(fNumber), ".")+numberOfDecimals+1)
Develop games in your browser. Powerful, performant & highly capable.
I was looking for this like crazy