cancel
Showing results for 
Search instead for 
Did you mean: 

Any std funtion(s) for Zero-padded, 2 decimal value, without the deci point

Former Member
0 Kudos

Hi,

We want Zero-padded, two decimal value, without the decimal point. For example if it is 14.31, we need 001431.

I have done "multiply" with 100 and "formatNumber" as '000000'

SFIeld --> multiply * 100 --> formatNumber (000000) --> TField

It works good for values with decimal like above 14.31, does it work for everything else too? I mean for 12 it is populating as 001200. Is this best approach? Is there any other std funtions or UDF sample available?

Regards,

N@v!n

Accepted Solutions (0)

Answers (3)

Answers (3)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi N@v!n / Gupta,

Both of your solutions works fine.

It may fail if input is '12.347', then output will be '001235'. Note: '001234.7' is rounded '001235'.

If youu2019re sure that you will not get more than 2 digits after decimal, your solution will always work.

Regards,

Raghu_Vamsee

Former Member
0 Kudos

Hi,

Use these 2 standard functions in this order:

1) ReplaceWith :: replace dot(.) with empty string

2) formatNum (000000)

I hope you dont get input value as 12.00

In that case you can create a UDF.

Regards

Former Member
0 Kudos

>

> Hi,

>

> We want Zero-padded, two decimal value, without the decimal point. For example if it is 14.31, we need 001431.

> I have done "multiply" with 100 and "formatNumber" as '000000'

>

> SFIeld --> multiply * 100 --> formatNumber (000000) --> TField

>

> It works good for values with decimal like above 14.31, does it work for everything else too? I mean for 12 it is populating as 001200. Is this best approach? Is there any other std funtions or UDF sample available?

>

> Regards,

> N@v!n

public void convert_number(String[] FieldValue,ResultList result,Container container){

FieldValue = FieldValue * 100;

result.addValue(FieldValue);

}