Here's a code snippet I just made which will cut a given number to a set number of decimals. It might give someone else an idea...
Code: Select all
//Change this to what you are using as a separator
Let>DecimalSeparator=.
//Change this to the number of decimals you want
Let>NumbersOfDecimals=2
//Mess around with this...
Let>ValueToRound=121210125.490521010210
Let>NumbersOfDecimals_Temp=%NumbersOfDecimals%+1
Let>RegExPattern=(\d+\%DecimalSeparator%)\d{0,%NumbersOfDecimals_Temp%}
RegEx>%RegExPattern%,%ValueToRound%,0,MatchArray,NumMatches,,,
If>NumMatches>0
Let>RegExPattern=%DecimalSeparator%([0-9]){0,%NumbersOfDecimals%}(?=[5-9])
RegEx>%RegExPattern%,%MatchArray_1%,0,,NumMatches,,,
If>NumMatches>0
Let>RegExPattern=(\d+\%DecimalSeparator%)\d{0,%NumbersOfDecimals%}
RegEx>%RegExPattern%,%MatchArray_1%,0,MatchArray,NumMatches,,,
RegEx>\%DecimalSeparator%,%MatchArray_1%,0,,NumMatches,1,.,MatchArray_1
Let>AddRound={1/(10^%NumbersOfDecimals%)}
Let>MatchArray_1=%MatchArray_1%+%AddRound%
RegEx>\.,%MatchArray_1%,0,,NumMatches,1,%DecimalSeparator%,MatchArray_1
Else>
Let>RegExPattern=(\d+\%DecimalSeparator%)\d{0,%NumbersOfDecimals%}
RegEx>%RegExPattern%,%MatchArray_1%,0,MatchArray,NumMatches,,,
RegEx>\.,%MatchArray_1%,0,,NumMatches,1,%DecimalSeparator%,MatchArray_1
Endif>
MDL>MatchArray_1
Else>
MDL>No " %DecimalSeparator% " found!%CRLF%%CRLF%%ValueToRound%
Endif>