Page 1 of 1

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

Posted: Thu May 15, 2014 1:11 pm
by Brian Irr

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


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

Posted: Thu May 15, 2014 2:02 pm
by Kateryna Grynko

Hi Brian,

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


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

Posted: Thu May 15, 2014 2:24 pm
by Brian Irr

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?


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

Posted: Thu May 15, 2014 2:35 pm
by Brian Irr

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..


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

Posted: Thu May 15, 2014 2:37 pm
by Evgene Karachevtsev

Hello Brian,

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