Mercurial > repos > IBBoard
view Lang/IBBMath.cs @ 79:a70d89de1435
Re #32: Add staged loading of translations
* Add "extends" attribute to schema so that translation files can define what they extend
* Add "get parent language" method to extractor
* Move loader to using XML translation sets
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 09 Apr 2010 19:48:51 +0000 |
parents | 298b2ff956bb |
children |
line wrap: on
line source
// This file (IBBMath.cs) is a part of the IBBoard project and is copyright 2009 IBBoard // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. // using System; namespace IBBoard.Lang { [Obsolete("Use IBBoard.CustomMeth.IBBMath instead")] public enum RoundType { Up, Down, Banker, UpToHalf, DownToHalf, BankerToHalf } /// <summary> /// IBBMath provides a number of custom Maths functions based on the core Math classes. /// </summary> [Obsolete("Use IBBoard.CustomMeth.IBBMath instead")] public class IBBMath { /// <summary> /// Rounds a number to the closest half, with a bias towards whole numbers. This is equivalent to 'round-to-even' in that /// 0.25 is rounded down to 0.0 and 0.75 is rounded up to 1.0 so that a bias isn't introduced by rounding. /// </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 /// </returns> public static double RoundToHalf(double number) { return IBBoard.CustomMath.IBBMath.RoundToHalf(number); } /// <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 IBBoard.CustomMath.IBBMath.FloorToHalf(number); } /// <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 IBBoard.CustomMath.IBBMath.CeilToHalf(number); } /// <summary> /// Returns the number rounded as defined by the <code>roundType</code> /// </summary> /// <param name="number"> /// The <see cref="System.Double"/> to round /// </param> /// <param name="roundType"> /// The way in which <code>number</code> should be rounded /// </param> /// <returns> /// The rounded <see cref="System.Double"/> /// </returns> public static double Round(double number, RoundType roundType) { IBBoard.CustomMath.RoundType newRoundType = (IBBoard.CustomMath.RoundType) Enum.Parse(typeof(IBBoard.CustomMath.RoundType), roundType.ToString()); return IBBoard.CustomMath.IBBMath.Round(number, newRoundType); } /// <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 IBBoard.CustomMath.IBBMath.Round(number, roundUp); } } }