changeset 33:8971a1c48dbf

Re #18 - Add rounding to half methods * Add Floor method that rounds down to a half * Add Ceiling method that rounds up to a half
author IBBoard <dev@ibboard.co.uk>
date Sun, 17 May 2009 19:22:53 +0000
parents 267cd5ce66ff
children d597feec5dd4
files Lang/IBBMath.cs
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Lang/IBBMath.cs	Sun May 17 18:54:11 2009 +0000
+++ b/Lang/IBBMath.cs	Sun May 17 19:22:53 2009 +0000
@@ -23,5 +23,33 @@
 		{
 			return Math.Round(number * 2) / 2;
 		}
+		
+		/// <summary>
+		/// Returns the largest whole or half number that is less than or equal to the specified number.
+		/// </summary>
+		/// <param name="number">
+		/// The <see cref="System.Double"/> to round to the nearest 0.5
+		/// </param>
+		/// <returns>
+		/// <code>param</code> rounded to the nearest 0.5 that is less than or equal to <code>param</code>
+		/// </returns>
+		public static double FloorToHalf(double number)
+		{
+			return Math.Floor(number * 2) / 2;
+		}
+		
+		/// <summary>
+		/// Returns the smallest whole or half number that is greater than or equal to the specified number.
+		/// </summary>
+		/// <param name="number">
+		/// The <see cref="System.Double"/> to round to the nearest 0.5
+		/// </param>
+		/// <returns>
+		/// <code>param</code> rounded to the nearest 0.5 that is greater than or equal to <code>param</code>
+		/// </returns>
+		public static double CeilToHalf(double number)
+		{
+			return Math.Ceiling(number * 2) / 2;
+		}
 	}
 }