View Single Post
  #2 (permalink)  
Old 08-07-2007, 08:29 AM
mathias mathias is offline
Member
 
Join Date: Jul 2007
Posts: 40
mathias is on a distinguished road
Have you tried adding .5 then converting to an Int?
Code:
totalOrganisms = (int)((initialOrganisms * Math.pow(growthRate,growPeriod))+.05);
This method will do the math first, then round. Since converting to an Int from a double just cuts off everything after the decimal, adding .5 will "round up" correctly.
Greetings.
Reply With Quote