August 4, 201015 yr I have several separate number fields that were entered with values like this: 4.23 13.7 .52 STEP 1: I need them to be padded with trailing zeros like this: 4.2300 13.7000 .5200 STEP 2: and then I need them to be joined as a text string like this: 4.2300|13.7000|.5200 I can handle writing the calculation for step 2, but I am trying to determine the simplest code to use for step 1. Any suggestions? Thanks.
August 4, 201015 yr N::Number & If( (Length( N::Number-Int ( N::Number))<5 ) and (Length( N::Number-Int ( N::Number))>1 ) ;Right ( "0000"; 4-Length( N::Number-Int ( N::Number) ) );"") & If( (Length( N::Number-Int ( N::Number))=1 ) ;".0000";"") should work, or implement as custom function if desired. N::Number is the number to round. The number less its INTeger component is the decimal part of the number; the length of the decimal part determines how many digits are present. Hence 4-the digits present equals the number of zeros to postfix to the value (length function counts decimal point). The special case of no digits (whole number) requires also that a decimal point be postfixed to the value. The second IF could alternately be handled with a CASE function.
August 4, 201015 yr Try: Let ( r = Round ( number ; 4 ) ; Int ( r ) & SerialIncrement ( ".0000" ; Mod ( r ; 1 ) * 10000 ) ) Note that this assumes non-negative numbers.
March 24, 201510 yr Try: Let ( r = Round ( number ; 4 ) ; Int ( r ) & SerialIncrement ( ".0000" ; Mod ( r ; 1 ) * 10000 ) ) Note that this assumes non-negative numbers. An old thread I know but… is there a simple way to get this to work for negative numbers? thanks
March 25, 201510 yr Try = Let ( [ r = Round ( number ; 4 ) ; a = Abs ( r ) ] ; Case ( r < 0 ; "-" ) & Int ( a ) & SerialIncrement ( ".0000" ; Mod ( a ; 1 ) * 10000 ) )
Create an account or sign in to comment