David was modifying a report produced by one of his company's applications and disabled rounding for debugging purposes. He thought it was a bit strange that the Tons field overflowed with itsy-bitsy fractions (such as 22.500002480200558937997962267231), especially considering the incoming pounds data was in large whole numbers (such as 45000). Looking at the PoundsToTons() function, David figured that the original code must have gotten a drastically different answer when asking How many pounds are in a ton? ...

public static decimal PoundsToTons(decimal pounds)
{
  decimal poundFactor = 0.4535924m;
  decimal tonFactor = 907.1847m;
  return Decimal.Divide((Decimal.Multiply(pounds, poundFactor)), tonFactor);
}
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!