Snaik Posted October 17, 2012 Share Posted October 17, 2012 I want to get a divided results to only show two numbers after the coma. how do i do that ? like : 9 divided by 7 = 1,28571429 i only want it to show "1,28". Sorry for asking too much questions . Link to comment
Aibo Posted October 17, 2012 Share Posted October 17, 2012 local n = tonumber(string.format("%.2f", 9/7)) -- n == 1.29 PS: if you dont need it as a number for further calculations (like if you're just going to display it somewhere), you can drop tonumber(). but keep in mind that it will add zeros to integers (like 9/9 will result in 1.00 without tonumber) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now