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 :: for loop roblox 
Lua :: lua how to make a loop 
Lua :: lua table unpack 
Lua :: append to table lua 
Lua :: get last characters of string lua 
Lua :: lua string to date 
Lua :: lua function 
Lua :: lua comments 
Lua :: roblox lua get game place id 
Lua :: How to Register a command in Lua 
Lua :: check if string is in string[] c# 
Lua :: lua to integer 
Lua :: awesomewm wibar configuration transparent 
Lua :: how to see greatest value in a table lua 
Lua :: roblox can I have player animations on the server 
Matlab :: matlab inverse z transform 
Matlab :: pyspark dense 
Matlab :: matlab nxm array 
Basic :: how to send basic auth using fetch 
Basic :: Detailview with form mixing 
Elixir :: elixir random number 
Elixir :: elixir eval ast 
Elixir :: elixir nested if 
Scala :: find a list of strings inside string scala 
Actionscript :: rabbitmq docker cant connect localhost 
Excel :: excel number of column 
Perl :: read a file in perl 
Pascal :: subrange variables pascal 
Powershell :: get-childitem supress errors silently 
Clojure :: clojure write file 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =