mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-16 16:02:54 +02:00
luahttp: make rounding function resilient to strings
Because somehow strings are used to represent decimals... Fixes #6815
This commit is contained in:
parent
b59a771680
commit
78ee8bbd04
@ -31,7 +31,13 @@ local dkjson = require ("dkjson")
|
||||
|
||||
--Round the number to the specified precision
|
||||
function round(what, precision)
|
||||
if what then return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision) else return "" end
|
||||
if type(what) == "string" then
|
||||
what = common.us_tonumber(what)
|
||||
end
|
||||
if type(what) == "number" then
|
||||
return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--split text where it matches the delimiter
|
||||
|
Loading…
Reference in New Issue
Block a user