I have this script performing a calculation on a page on my site:

<script language="JavaScript">

function compute_weight(form)

{

var weight = form.wt.value;

var pgs = form.pgs.value;

var ppi = form.ppi.value;

var hite = form.ht.value;

if (weight > 0.0) {

form.totwid.value = int_zero( weight * 2 )+(pgs/ppi)+0.5;

form.totht.value = int_zero( hite )+ 0.5;

form.spine.value = int_zero( pgs)/ (ppi);

form.hite1.value = int_zero(hite);

form.hite2.value = int_zero(hite);

form.wid1.value = int_zero(weight);

form.wid2.value = int_zero(weight);

form.spinetype.value = int_zero( pgs)/ (ppi) -.125;

}

}

// Function to return 0 if result is <1

function int_zero(x)

{

if ( x < 1 )

return 0 ;

else

return parseInt( x ,10 );

}

</script>

At times, depending on the values entereed into my form, I can end up with a

number like 13.011945392491468. 15 decimal places is just too confusing.

Is there a way I can round this to 3? Or even better, is there away to make

this value appear as a fraction? If you need more code from the page, it's

at

www.integratedbook.com/pbkcalc.html. Thanks for your help.

--

Jason

Remove nospam for email replies