Firetron's CountDecimals
stableDescription
Returns the number of decimal places in a number.
HaasScript
-- ============================================================================
-- Firetron's CountDecimals
--
-- Returns the number of decimal places in a number.
--
-- Discord: @FiretronP75
-- ============================================================================
-- ========================================================
-- Definition
-- ========================================================
DefineCommand('CountDecimals', 'Returns the number of decimal places in a number.')
-- ========================================================
-- Parameters
-- ========================================================
local value = DefineParameter(NumberType, 'value', 'something like 1.234', true, 1.234, 'MinimumTradeAmount, ParseTradePrice')
-- ========================================================
-- Output
-- ========================================================
local valueString = Parse(value, StringType)
local splitString = StringSplit(valueString, '.')
local output
if #splitString == 1 then
output = 0
else
local decimalString = splitString[2]
output = #decimalString
end
DefineOutput(NumberType, output, 'the number of decimal places in a number')
2 Comments
Sign in to leave a comment.
Thank you for your help on this pshai
No, thank you for making it awesome ;)