Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3529 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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.

  • 4 years later...
Posted

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

Posted

Try =

Let ( [
r = Round ( number ; 4 ) ;
a = Abs ( r )
] ;
Case ( r < 0 ; "-" ) & Int ( a ) & SerialIncrement ( ".0000" ; Mod ( a ; 1 ) * 10000 )
)
  • Like 2

This topic is 3529 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.