By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

Rounding down in hundreds

P: 17
Hi all, here's a quick for which I haven't been able to track down a quick solution on Google. The 2 amounts delivered ('outgoings' and 'alreadyprotected' will always be between 0 and 9999.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  function unprotectedcalc(){
  3.     var outgoings = document.getElementById('EssOutgoings');
  4.     var alreadyprotected = document.getElementById('ProtectedPayments');
  5.     var result = document.getElementById('UnprotectedResult');
  6.  
  7.     var initialresult = parseInt(outgoings.value)- parseInt(alreadyprotected.value);
  8.     initialresult /= 100;
  9.     initialresult = Math.round(initialresult);
  10.     initialresult *= 100;
  11.     result.value = initialresult;
  12.  
  13.  }
  14.  
  15.  
This needs to always round down, rather than your regular type rounding: is this possible in a quick way rather than simply extending the above?

IE 6 XP Pro

Many thanks in advance

J
Oct 16 '07 #1
Share this Question
Share on Google+
1 Reply


100+
P: 428
Expand|Select|Wrap|Line Numbers
  1. var initialresult = parseInt(outgoings.value)- parseInt(alreadyprotected.value);
  2. result.value =  Math.floor(initialresult/100)*100;
Oct 16 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.