...

View Full Version : needs help with exponent and other math. stuff



neurot_1
08-20-2004, 02:03 AM
Hi everyone,

I need some help with math. stuff because I am not too proficient with it.
If i have this equation:

1 - (1+b)n
(where n is an exponent)
how does it translate in javascript?

Also, is there a way to round up to the upper thousand value?
Like if I have a result that is $12867, if I round it up to the nearest thousand, my result is going to be $13000.
It sounds a bit tricky to do.

Any help would be much appreciated, thanks!

jkd
08-20-2004, 02:29 AM
1 - Math.pow(1+b, n);



Number.prototype.toNearest = function(num) { // num is an exponent of 10
return Math.round(this/num)*num;
}

12867 .toNearest(1000) == 1300

dumpfi
08-20-2004, 05:43 PM
To round up:

Number.prototype.toNearest = function(num) { // num is an exponent of 10
return Math.ceil(this/num)*num;
}

12867 .toNearest(1000) == 1300dumpfi

neurot_1
08-20-2004, 09:41 PM
Thanks a lot , guys! Much appreciated~ :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum