cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal Value

Former Member
0 Kudos

I am dividing my Premium by 100 and then sending to the targetamt.

Premium is of type intege. 100 is constant and Targetamt is string.

The problem

-


Premium is 10000 then I am expecting Targetamt as 100.00, but what I am getting is 100.

On the other hand

if Premium is 10035 then I am getting the correct value 100.35.

I have tried changing the Premium data type to Float, Decimal, but every time for the whole numbers the Decimal portion is getting cut.

Any Suggestions please

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

you have to do it insid ea user advanced function

(inside graphical mapping for example)

change the strig into an integer

divide it and change it back to string

BTW

string to int:

someint = Integer.parseInt(somestring);

int/double to string:

somestring = String.valueof(someinteger);

Regards,

michal

Former Member
0 Kudos

Thanks Mich. Could you please provide me how should I write a Function. I have never done before. I am passing one value my amount and getting back again targetamt.

I will also try in the mean time.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

try this:

create a simpl function with one parameter

double resultset;

int newint = Integer.parseInt(a);

int dividbythis = 100;

resultset = newint/dividbythis;

NumberFormat formatter = new DecimalFormat(".00");

String myvalue = formatter.format(resultset);

String finalvalue = String.valueOf(myvalue);

return finalvalue;

BTW

add

java.text.DecimalFormat;

and java.text.NumberFormat;

to your simple function

Regards,

michal

Message was edited by: Michal Krawczyk

Former Member
0 Kudos

Thanks Mich. It worked out. wonderful and thanks again.

-


Imports: java.text.DecimalFormat;java.text.NumberFormat;

public String Divide(String a,Container container){

double resultset;

int newint = Integer.parseInt(a);

int dividbythis = 100;

resultset = newint/dividbythis;

NumberFormat formatter = new DecimalFormat(".00");

String myvalue = formatter.format(resultset);

String finalvalue = String.valueOf(myvalue);

return finalvalue;

}

-


MichalKrawczyk
Active Contributor
0 Kudos

glad it works

regards,

michal

Answers (0)