445,909 Members | 2,016 Online
Need help? Post your question and get tips & solutions from a community of 445,909 IT Pros & Developers. It's quick & easy.

# Some decimal math.

 P: n/a int sqrft = 1335; decimal pricePerSqr = 18.33m; decimal pricePerYear = Math.Round(pricePerSqr * sqrft, 2, MidpointRounding.AwayFromZero); decimal pricePerMonth = Math.Round(pricePerYear / 12, 2, MidpointRounding.AwayFromZero); Console.WriteLine("/Sqr:"+pricePerSqr.ToString()); Console.WriteLine("/Year:"+pricePerYear.ToString()); Console.WriteLine("/Mth:"+pricePerMonth.ToString()); // Find PricePerSqr given PerMonth. pricePerMonth = 2039.21m; pricePerYear = pricePerMonth * 12; pricePerSqr = Math.Round(pricePerYear / sqrft, 2, MidpointRounding.AwayFromZero); Console.WriteLine("-----------"); Console.WriteLine("/Sqr:"+pricePerSqr.ToString()); Console.WriteLine("/Year:"+pricePerYear.ToString()); Console.WriteLine("/Mth:"+pricePerMonth.ToString()); /Sqr:18.33 /Year:24470.55 /Mth:2039.21 ----------- /Sqr:18.33 /Year:24470.52 /Mth:2039.21 Should I be doing something different to make both ways add up the same. Notice the Year price is slightly different when backing in from pricePerMonth. TIA -- William Stacey [MVP] Jun 8 '06 #1