Click to See Complete Forum and Search --> : Output of number


florida
05-20-2003, 06:17 AM
I have an output of a total but now need it give it to me in dollars.

So if I have a number output of 785.9343433

I would need it to be transfered to $785.93

I am assuming I need to get this to work with substrings?

Charles
05-20-2003, 06:31 AM
<script type="text/javascript">
<!--
alert(Math.round(Math.PI * 100) / 100);
// -->
</script>

Ther's also a Number.toFixed() method available on late model browsers.

florida
05-20-2003, 07:41 AM
How would I get that into this calculation??

return mytot * (mynum2 / (1 - (1/Math.pow(1 + mynum2,mynum3))));

AdamBrill
05-20-2003, 07:55 AM
Try using this:num = 785.9343433;
num = Math.round(num*100)/100;
dec = String(num).length-String(num).indexOf('.')-1;
for(x=0; x<dec; x++){num = String(num)+"0";}
num = "$"+num;
return num;

florida
05-20-2003, 08:11 AM
Thanks to both of you. It now works the way it should.