1LoL1 Posted January 27, 2016 Posted January 27, 2016 Hello, how i can use to number math.floor and math.round not work now its 5.14542123232 i need 5.1 how i can do please?
Army@1 Posted January 27, 2016 Posted January 27, 2016 function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) end -- example print(round(5.14542123232, 1)) -- result: 5.1
1LoL1 Posted January 27, 2016 Author Posted January 27, 2016 function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) end -- example print(round(5.14542123232, 1)) -- result: 5.1 Not work number 5.14542123232 was only example. I need for all numbers.
Army@1 Posted January 27, 2016 Posted January 27, 2016 Not work number 5.14542123232 was only example. I need for all numbers. What sort of numbers?
1LoL1 Posted January 27, 2016 Author Posted January 27, 2016 Not work number 5.14542123232 was only example. I need for all numbers. What sort of numbers? sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) speed = ((sx^2 + sy^2 + sz^2)^(0.5)*180)
Army@1 Posted January 27, 2016 Posted January 27, 2016 This will round numbers to 10ths. In other words, 0.1, 25.9, 56.2, etc... sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 1) Or, if you want just integers sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 0)
1LoL1 Posted January 27, 2016 Author Posted January 27, 2016 This will round numbers to 10ths. In other words, 0.1, 25.9, 56.2, etc... sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 1) Or, if you want just integers sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 0) Not work it's same what i had.
1LoL1 Posted January 28, 2016 Author Posted January 28, 2016 It probably should. What did it output then? Not work. It's the same what i had..
NewbProgramming Posted January 28, 2016 Posted January 28, 2016 You're not describing specifically what you want so how could we help you? Be more specific on what you want.
1LoL1 Posted January 28, 2016 Author Posted January 28, 2016 You're not describing specifically what you want so how could we help you?Be more specific on what you want. All you have on start.
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