I'm trying to get the number of decimals of a passed number, so I wrote:
Code: Select all
function getDecimalNumber numericValue
if (numericValue is not a number) then return -1
if ("." is in numericValue) then
put 20 into maxDecimals
put 1 into multiplier
repeat with i = 1 to maxDecimals
multiply multiplier by 10
get numericValue * multiplier
if (it is an integer) then return i
end repeat
return -1 // too much decimals
else
return 0
end if
end getDecimalNumber
I don't understand why, but maybe there is a better way to do that?