Číslo kola lua

Příklady kódu

3
0

číslo kola lua

local number = 15.57
local number2 = 15.23

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

kolo na nejbližší číslo 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))

Související stránky

Související stránky s příklady

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................