changeset 39:ebc01964a918

* Add short method to round up or down based on a boolean - useful for compacting rounding up/down calls when they need to be done inline no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sun, 09 Aug 2009 11:20:25 +0000
parents a47736adb1e8
children c71855e241fc
files Lang/IBBMath.cs
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Lang/IBBMath.cs	Sun Jul 05 09:46:12 2009 +0000
+++ b/Lang/IBBMath.cs	Sun Aug 09 11:20:25 2009 +0000
@@ -112,5 +112,22 @@
 
 			return val;
 		}
+		
+		/// <summary>
+		/// Returns the number rounded up or down to the closest whole number.
+		/// </summary>
+		/// <param name="number">
+		/// The <see cref="System.Double"/> to round
+		/// </param>
+		/// <param name="roundUp">
+		/// <code>true</code> to round up, else rounds down
+		/// </param>
+		/// <returns>
+		/// The rounded <see cref="System.Double"/>
+		/// </returns>
+		public static double Round(double number, bool roundUp)
+		{
+			return (roundUp ? Math.Ceiling(number) : Math.Floor(number));
+		}
 	}
 }