Brian Irr
Posts: 0
Joined: Tue Sep 17, 2013 1:25 pm

math calculation returning infinity, also need to set 2 decimal places.

I am having a problem with a math calculation returning infinity and I would like to set the decomal places to 2 outside of appery i did it with .toFixed(2).

document.tipForm.splitAnswer.value = " $ " + (amount/split).toFixed(2);

Please see the pic. and I have shared the app so that you can look at the Javascript.

App name is Geo Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

math calculation returning infinity, also need to set 2 decimal places.

Hi Brian,

What are the values of variables 'amount' and 'split' at the moment?

Brian Irr
Posts: 0
Joined: Tue Sep 17, 2013 1:25 pm

math calculation returning infinity, also need to set 2 decimal places.

Ok while I was getting the values i found that I had an extra = sign

I had if (split === " ")
{
split = 1; }

I changed it to only 2 = signs and now it works.

I was trying to say if split fild was left blank the the defalt split amount is 1.

Now I am getting values of Amount is 165 , split amount is 82.5

How do I force it to display 165.00 and 82.50?

Brian Irr
Posts: 0
Joined: Tue Sep 17, 2013 1:25 pm

math calculation returning infinity, also need to set 2 decimal places.

I Found tha answer to setting the decimal places

Old
Appery('splitAnswer').val(" $ " + (splitAmt=Math.round(splitAmt*100)/100);

New
Appery('splitAnswer').val(" $ " +(splitAmt=Math.round(splitAmt*100)/100).toFixed(2));

Thank you for your help..

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

math calculation returning infinity, also need to set 2 decimal places.

Hello Brian,

Thank you for the update. Do not hesitate to contact us if you need any further help.

Return to “Issues”