Search
 
SCRIPT & CODE EXAMPLE
 

LUA

lua round number

local number = 15.57
local number2 = 15.23

print(math.floor(number + 0.5)) --16
print(math.floor(number2 + 0.5)) --15
Comment

round to the nearest number lua

--You can round answers to the nearest multiple of a number
--For example, rounding 13 to the nearest multiple of 3 is 12, since 12 is
--divisible by 3
local number = 15.2
local multiple = 3 --the multiple you choose
print(math.floor(number/multiple+0.5)*multiple --Add 0.5
  
--Or just round to the nearest whole number
print(math.floor(number + 0.5))
Comment

PREVIOUS NEXT
Code Example
Lua :: luau make kill brick 
Lua :: tostring lua 
Lua :: roblox difference between __index and __newindex 
Lua :: roblox debounce 
Lua :: roblox tween color 
Lua :: try except lua 
Lua :: lua float to int 
Lua :: roblox how to find value in table 
Lua :: roblox key pressed script 
Lua :: roblox wait for character 
Lua :: lua event 
Lua :: how to delete parts with a script in roblox studio 
Lua :: What is BreakJoints roblox? 
Lua :: fivem commands lua example 
Lua :: Tool script example for lua 
Lua :: lua hash table length 
Lua :: lua input 
Lua :: check player role in group 
Lua :: how to add a damage decimal in roblox studio 
Lua :: name is not a valid member of Folder roblox 
Matlab :: matlab if not true 
Matlab :: how to run a p code matlab 
Matlab :: matlab new line in string 
Basic :: split to arraylist vb.net 
Elixir :: elixir catch 
Elixir :: how to split a string in elixir 
Scala :: scala string to boolean 
Scala :: scala list of options to option of list 
Excel :: google sheets sort column by item frequency 
Perl :: perl remove all whitespace 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =