@sheikah
After hours of tinkering... Success!
function GetTruncatedNumber02(num, dp)
local pwr = math.pow(10, dp)
num = math.floor(num * pwr)
WARN(' pwr: ', pwr,' num', num,' num / pwr: ', num / pwr)
local result = num / pwr
local fmtStr = string.format('%%0.%sf',dp)
number = string.format(fmtStr, result)
return number
end
Results
Math Truncate: 18.3671875 Decimals given, 1, 2, 3
Decimal: 1 pwr: 10 num 183 num / pwr: 18.299999237061
Output one after string filter: 18.3
Decimal: 2 pwr: 100 num 1836 num / pwr: 18.360000610352
Output two after string filter: 18.36
Decimal: 3 pwr: 1000 num 18367 num / pwr: 18.367000579834
Output three after string filter: 18.367
Ended up combining a few methods to get this result. Not sure how it would behave with negative values but thats for tomorrow. (tired)
Resin