Posted 15 January 2015 - 03:01 PM
I wanted to show only 2 positions after the decimal point. To do that I wrote this little piece of code:
The problem is, that it prints a number like 87.044352 instead of 87.04. I know that I can round it when multiplying by 100, using math.floor and dividing by 100 but string.format is there for a reason :)/>
Is it possible that ComputerCraft doesn't implement this case? It works fine on my Linux lua shell, though.
print(string.format("2.2f", percentage))
The problem is, that it prints a number like 87.044352 instead of 87.04. I know that I can round it when multiplying by 100, using math.floor and dividing by 100 but string.format is there for a reason :)/>
Is it possible that ComputerCraft doesn't implement this case? It works fine on my Linux lua shell, though.