Hello,
a!localVariables( local!number: todecimal(370737340900000.00), /* Replace this with your input number */ local!chunkSize: 7, /* Define chunk size (7 digits) */ local!divisor: 10 ^ local!chunkSize,
local!chunks: {}, /* List to store chunks */
local!x:a!forEach( items: enumerate(ceiling(log(local!number)/log(local!divisor)) + 1), /* Arbitrarily large number to iterate through */ expression:{ local!iteration:enumerate(ceiling(log(local!number)/log(local!divisor)) + 1), local!chunk: mod(local!number, local!divisor), /* Get last 7 digits */ local!number: round(local!number / local!divisor, 0) } ),
/* Reverse the chunks list to maintain the correct order */ reverse(local!chunks))
I want to achieve try to split the big decimal into 7 digit numbers, I want the result in the "local!x" {8765431, 7373409, 370}
I hope the question is clear, let me know how to achieve this.
Discussion posts and replies are publicly visible
There can be other ways of achieving this too.
a!localVariables( local!number: "37073734098765431", /* Replace this with your input number */ local!chunkSize: 7, /* Define chunk size (7 digits) */ local!chunks: {}, /* List to store chunks */ local!x:reverse(code(local!number)), /* Reverse the chunks list to maintain the correct order */ a!forEach( items: enumerate(ceiling(length(local!x)/local!chunkSize))+1, expression: tointeger(joinarray( reverse(char(reject( a!isNullOrEmpty, index( local!x, enumerate((local!chunkSize))+if(fv!isFirst,1,(local!chunkSize*(fv!item-1))+1), null ) ))) )) ) )
a!localVariables( local!text: char( code( "21121212u1i2ui12i1iwjansjnajnsjansnansa" ) ), local!length: 7, local!arrayWithIdentifier: a!flatten( a!forEach( items: local!text, expression: { if( mod(fv!index, local!length) = 0, { fv!item, ";" }, { fv!item } ) } ) ), local!splitData: split(concat(local!arrayWithIdentifier), ";"), local!splitData )
a!localVariables( local!value: 370737340900000.00, local!chunkSize: 3, local!textValue: text(local!value, "0"), a!forEach( items: enumerate(ceiling(len(local!textValue) / local!chunkSize)), expression: mid(local!textValue, (fv!item * local!chunkSize) + 1, local!chunkSize) ) )
Thanks Stefan Helzle , Much easier