NameSilo

Simple Java Question -19NP reward

Spaceship Spaceship
Watch

ATWatts

Established Member
Impact
2
How do you limit the number of digits that are displayed when outputting a number using Java. FOr example instead of 23.032345434 I want to display 23.03.

I'm trying to limit the digits shown on my little calculator at www.GasCreditCard.biz.

19 NP to whoever answers my question correctly first. That means that the answer directly has to lead to my problem being fixed.

Code:
function calculatesavings(form)
{
MPG = form.MPG.value;
MDPY = form.MDPY.value;
PPG = form.PPG.value;
GTS = form.GTS.value;
G=MDPY/MPG;
CWS=G*PPG;
SPY=CWS*.1;
SPM=SPY/12;
SPG=.1*PPG;
SPT=SPG*GTS;
form.SPY.value=SPY;
form.SPM.value=SPM;
form.SPT.value=SPT;
form.SPG.value=SPG;
}
</script>
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
Try that :

Code:
function calculatesavings(form)
{
MPG = form.MPG.value;
MDPY = form.MDPY.value;
PPG = form.PPG.value;
GTS = form.GTS.value;
G=MDPY/MPG;
CWS=G*PPG;
SPY=CWS*.1;
SPM=SPY/12;
SPG=.1*PPG;
SPT=SPG*GTS;
form.SPY.value=Math.round(SPY*100)/100;
form.SPM.value=Math.round(SPM*100)/100;
form.SPT.value=Math.round(SPT*100)/100;
form.SPG.value=Math.round(SPG*100)/100;
}
</script>
 
0
•••
Thanks

Thanks!!
 
1
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back