2001-07-24 Derek Holden <dholden@draper.com>
authorMiguel de Icaza <miguel@gnome.org>
Wed, 25 Jul 2001 05:15:40 +0000 (05:15 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 25 Jul 2001 05:15:40 +0000 (05:15 -0000)
* NumberStyles.cs: Added ECMA values for Allow types and default
styles.
2001-07-24  Derek Holden  <dholden@draper.com>

* Boolean.cs: Formatted to code style standard. Added GetTypeCode
which is really an IConvertible defined method.

* Byte.cs: Added a missing Parse method. Put in Parse and ToString
behavior, still need to do the main Parse and ToString.

* Char.cs: Added a bunch of missing ECMA methods. Commented a
specification discrepency. Still didn't any unicode stuff, though
every IsFoo(char c) method has an IsFoo(string, index)
counterpart, added wrappers for those.

* Convert.cs: Fixed NaN/Inf checking and double/float
rounding. Added ToType for IConvertible classes

* Double.cs: Fixed ECMA min and max values. Added IsInfinity /
IsNaN methods. Changed Inf/NaN internals.

* IConvertible.cs: Added comments for using
Convert.ToType. Changed return values to draft base values.

* Int16.cs: Added a missing Parse statement. Put in behavior for
overloaded ToString and Parse methods.

* Int32.cs: Added a missing Parse statement. Put in behavior for
overloaded ToString and Parse methods.

* Int64.cs: Added a missing Parse statement. Put in behavior for
overloaded ToString and Parse methods.

* Single.cs: Put in ECMA epsilon value. Added IsInfinity / IsNaN
methods. Changed Inf/NaN internals.

* SByte.cs: Added a missing Parse method. Put in Parse and
ToString behavior, still need to do the main Parse and ToString.

* UInt16.cs: Added a missing Parse statement. Put in behavior for
overloaded ToString and Parse methods.

* UInt32.cs: Added a missing Parse statement. Put in behavior for
overloaded ToString and Parse methods.

* UInt64.cs: Added a missing Parse statement. Put in behavior for
overloaded ToString and Parse methods.

svn path=/trunk/mcs/; revision=320

20 files changed:
mcs/class/corlib/System.Globalization/ChangeLog
mcs/class/corlib/System.Globalization/NumberStyles.cs
mcs/class/corlib/System/Boolean.cs
mcs/class/corlib/System/Byte.cs
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Char.cs
mcs/class/corlib/System/Convert.cs
mcs/class/corlib/System/DateTime.cs
mcs/class/corlib/System/Double.cs
mcs/class/corlib/System/IConvertible.cs
mcs/class/corlib/System/Int16.cs
mcs/class/corlib/System/Int32.cs
mcs/class/corlib/System/Int64.cs
mcs/class/corlib/System/SByte.cs
mcs/class/corlib/System/Single.cs
mcs/class/corlib/System/UInt16.cs
mcs/class/corlib/System/UInt32.cs
mcs/class/corlib/System/UInt64.cs
mcs/class/makefile
mcs/mcs/makefile

index 3415e8d6a05e64dd971e82486532059d6c07c809..d029e001544e259aab6ef9b49281731b9add6007 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-24  Derek Holden  <dholden@draper.com>
+
+       * NumberStyles.cs: Added ECMA values for Allow types and default
+       styles.
+
 2001-07-18  Michael Lambert <michaellambert@email.com>
 
         * DateTimeStyles.cs, NumberStyles.cs: Add.
index 0a9ac21844c9e4db32b3dc1ddb30a0088d67d5ad..9d16b716be0b8ff394fb22e1ee8364794bfdd0c7 100644 (file)
@@ -1,36 +1,45 @@
-//------------------------------------------------------------------------------\r
-// \r
-// System.Globalization.NumberStyles.cs \r
-//\r
-// Copyright (C) 2001 Michael Lambert, All Rights Reserved\r
-// \r
-// Author:         Michael Lambert, michaellambert@email.com\r
-// Created:        Thu 07/18/2001 \r
-//\r
-//------------------------------------------------------------------------------\r
-\r
-namespace System.Globalization\r
-{\r
-\r
-public enum NumberStyles\r
-{\r
-    AllowCurrencySymbol,\r
-    AllowDecimalPoint,\r
-    AllowExponent,\r
-    AllowHexSpecifier,\r
-    AllowLeadingSign,\r
-    AllowLeadingWhite,\r
-    AllowParentheses,\r
-    AllowThousands,\r
-    AllowTrailingSign,\r
-    AllowTrailingWhite,\r
-    Any,\r
-    Currency,\r
-    Float,\r
-    HexNumber,\r
-    Integer,\r
-    None,\r
-    Number,\r
-}\r
-\r
-} // Namespace\r
+//------------------------------------------------------------------------------
+// 
+// System.Globalization.NumberStyles.cs 
+//
+// Copyright (C) 2001 Michael Lambert, All Rights Reserved
+// 
+// Author:         Michael Lambert, michaellambert@email.com
+// Created:        Thu 07/18/2001 
+//
+// Modified:       7/20/01, Derek Holden (dholden@draper.com)
+//                 Added ECMA values for allows and masks for data types
+//
+//------------------------------------------------------------------------------
+
+namespace System.Globalization {
+
+       public enum NumberStyles 
+       {
+               None                 = 0x00000000,
+               AllowLeadingWhite    = 0x00000001,
+               AllowTrailingWhite   = 0x00000002,
+               AllowLeadingSign     = 0x00000004,
+               AllowTrailingSign    = 0x00000008,
+               AllowParentheses     = 0x00000010,
+               AllowDecimalPoint    = 0x00000020,
+               AllowThousands       = 0x00000040,
+               AllowExponent        = 0x00000080,
+               AllowCurrencySymbol  = 0x00000100,
+               AllowHexSpecifier    = 0x00000200,
+
+               Integer   = ( AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign ),
+               HexNumber = ( AllowLeadingWhite | AllowTrailingWhite | AllowHexSpecifier ),
+               Number    = ( AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | 
+                             AllowTrailingSign | AllowDecimalPoint  | AllowThousands ), 
+               Float     = ( AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | 
+                             AllowDecimalPoint | AllowExponent ),           
+               Currency  = ( AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | 
+                             AllowTrailingSign | AllowParentheses   | AllowDecimalPoint |
+                             AllowThousands    | AllowCurrencySymbol ), 
+               Any       = ( AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | 
+                             AllowTrailingSign | AllowParentheses   | AllowDecimalPoint |
+                             AllowThousands    | AllowExponent      | AllowCurrencySymbol ), 
+       }
+
+} // Namespace
index 804ad7ca066db4e8b8ce60cc8faaee970626ad28..c863f64728866d46b66b8e70bc76367a6272b350 100644 (file)
 
 namespace System {
 
-    /// <summary>
-    /// Represents the boolean values of logical true and false.
-    /// </summary>
-    /// The .NET Framework SDK lists this as implementing IConvertible,
-    /// though it's not done here or in the ECMA spec.
-    public struct Boolean : IComparable { //, IConvertible {
-
-       /// <value>
-       /// The String representation of Boolean False</value>  
-       public static readonly string FalseString;
+       /// <summary>
+       /// Represents the boolean values of logical true and false.
+       /// </summary>
+       // The .NET Framework SDK lists this as implementing IConvertible,
+       // though it's not done in the ECMA spec.
+       public struct Boolean : IComparable { //, IConvertible {
+               
+               /// <value>
+               /// The String representation of Boolean False
+               /// </value>    
+               public static readonly string FalseString;
 
-       /// <value>
-       /// The String representation of Boolean True</value>   
-       public static readonly string TrueString;
+               /// <value>
+               /// The String representation of Boolean True
+               /// </value>    
+               public static readonly string TrueString;
       
-       /// <value>
-       /// Internal bool value for for this instance</value>
-       //
-       // Hack: we tag it as public, so the source will compile.
-       public bool value;
+               /// <value>
+               /// Internal bool value for for this instance
+               /// </value>
+               //
+               // HACK: we tag it as public, so the source will compile.               
+               public bool value;
        
-       static Boolean() {
-           FalseString = "False";
-           TrueString = "True";
-       }
-
-       /// <summary>
-       /// Compares the current Boolean instance against another 
-       /// object.</summary>
-       /// <remarks>
-       /// Throws an ArgumentException if <c>obj</c> isn't null or 
-       // a Boolean.</remarks>
-       /// <param name="obj">The object to compare against</param>
-       /// <returns>
-       /// An int reflecting the sort order of this instance as 
-       /// compared to <c>obj</c>
-       /// -1 if this instance is false and <c>obj</c> is true
-       ///  0 if this instance is equal to <c>obj</c>
-       ///  1 if this instance is true and <c>obj</c> is false, 
-       ///    or <c>obj</c> is null</returns>
-       public int CompareTo(object obj) {
-           if(obj != null && !(obj is System.Boolean))
-               throw new ArgumentException
-                   ("Object is not a Boolean and is not a null reference");
+               static Boolean () 
+               {
+                       FalseString = "False";
+                       TrueString = "True";
+               }
 
-           // for case #3
-           if(obj == null || (value == true && (bool)obj == false))
-               return 1;
+               /// <summary>
+               /// Compares the current Boolean instance against another object.
+               /// </summary>
+               /// <remarks>
+               /// Throws an ArgumentException if <c>obj</c> isn't null or 
+               /// a Boolean.
+               /// </remarks>
+               /// <param name="obj">
+               /// The object to compare against
+               /// </param>
+               /// <returns>
+               /// An int reflecting the sort order of this instance as 
+               /// compared to <c>obj</c>
+               /// -1 if this instance is false and <c>obj</c> is true
+               ///  0 if this instance is equal to <c>obj</c>
+               ///  1 if this instance is true and <c>obj</c> is false, 
+               ///    or <c>obj</c> is null
+               /// </returns>
+               public int CompareTo (object obj) 
+               {
+                       if(obj != null && !(obj is System.Boolean))
+                               throw new ArgumentException
+                               ("Object is not a Boolean and is not a null reference");
+                       
+                       // for case #3
+                       if (obj == null || (value == true && (bool)obj == false))
+                               return 1;
            
-           // for case #2, else it's #1
-           return (value == (bool)obj) ? 0 : -1;
-       }
+                       // for case #2, else it's #1
+                       return (value == (bool)obj) ? 0 : -1;
+               }
        
-       /// <summary>
-       /// Determines whether this instance and another object represent the
-       /// same type and value.</summary>
-       /// <param name="obj">The object to check against</param>
-       /// <returns>
-       /// true if this instnace and <c>obj</c> are same value, 
-       /// otherwise false if it is not or null</returns>
-       public override bool Equals(Object obj) {
-           if(obj == null || !(obj is System.Boolean))
-               return false;
+               /// <summary>
+               /// Determines whether this instance and another object represent the
+               /// same type and value.
+               /// </summary>
+               /// <param name="obj">
+               /// The object to check against
+               /// </param>
+               /// <returns>
+               /// true if this instnace and <c>obj</c> are same value, 
+               /// otherwise false if it is not or null
+               /// </returns>
+               public override bool Equals (Object obj) 
+               {
+                       if (obj == null || !(obj is System.Boolean))
+                               return false;
 
-           return ((bool)obj) == value;
-       }
+                       return ((bool)obj) == value;
+               }
        
-       /// <summary>
-       /// Generates a hashcode for this object.</summary>
-       /// <returns>
-       /// An Int32 value holding the hash code</returns>
-       public override int GetHashCode() {
-           // TODO: Implement Boolean Hashcode
-           return 0;
-       }
+               /// <summary>
+               /// Generates a hashcode for this object.
+               /// </summary>
+               /// <returns>
+               /// An Int32 value holding the hash code
+               /// </returns>
+               public override int GetHashCode () 
+               {
+                       // Guess there's not too many ways to hash a Boolean
+                       return value ? 1 : 0;
+               }
 
-       /// <summary>
-       /// Returns a given string as a boolean value. The string must be 
-       /// equivalent to either TrueString or FalseString, with leading and/or
-       /// trailing spaces, and is parsed case-insensitively.</summary>
-       /// <remarks>
-       /// Throws an ArgumentNullException if <c>val</c> is null, or a 
-       /// FormatException if <c>val</c> doesn't match <c>TrueString</c> 
-       /// or <c>FalseString</c></remarks>
-       /// <param name="val">The string value to parse</param>
-       /// <returns>
-       /// true if <c>val</c> is equivalent to TrueString, 
-       /// otherwise false</returns>
-       public static bool Parse(string val) {
-           if(val == null)
-               throw new ArgumentNullException("Value is a null reference");
+               /// <summary>
+               /// Returns a given string as a boolean value. The string must be 
+               /// equivalent to either TrueString or FalseString, with leading and/or
+               /// trailing spaces, and is parsed case-insensitively.
+               /// </summary>
+               /// <remarks>
+               /// Throws an ArgumentNullException if <c>val</c> is null, or a 
+               /// FormatException if <c>val</c> doesn't match <c>TrueString</c> 
+               /// or <c>FalseString</c>
+               /// </remarks>
+               /// <param name="val">
+               /// The string value to parse
+               /// </param>
+               /// <returns>
+               /// true if <c>val</c> is equivalent to TrueString, 
+               /// otherwise false
+               /// </returns>
+               public static bool Parse (string val) 
+               {
+                       if (val == null)
+                               throw new ArgumentNullException ("Value is a null reference");
            
-           val = val.Trim();
+                       val = val.Trim ();
            
-           if(String.Compare(val, TrueString, true) == 0)
-               return true;
+                       if (String.Compare (val, TrueString, true) == 0)
+                               return true;
            
-           if(String.Compare(val, FalseString, true) == 0)
-               return false;
+                       if (String.Compare (val, FalseString, true) == 0)
+                               return false;
            
-           throw new FormatException
-               ("Value is not equivalent to either TrueString or FalseString");
-       }
+                       throw new FormatException
+                       ("Value is not equivalent to either TrueString or FalseString");
+               }
 
-       /// <summary>
-       /// Returns a string representation of this Boolean object.</summary>
-       /// <returns>
-       /// <c>FalseString</c> if the instance value is false, otherwise 
-       /// <c>TrueString</c></returns>
-       public override string ToString() {
-           return value ? TrueString : FalseString;
-       }
-    }
-}
+               /// <summary>
+               /// Returns a string representation of this Boolean object.
+               /// </summary>
+               /// <returns>
+               /// <c>FalseString</c> if the instance value is false, otherwise 
+               /// <c>TrueString</c>
+               /// </returns>
+               public override string ToString () 
+               {
+                       return value ? TrueString : FalseString;
+               }
+               
+               // =========== IConvertible Methods =========== //
+
+               public TypeCode GetTypeCode () 
+               { 
+                       return TypeCode.Boolean;
+               }
+
+       } // System.Boolean
+
+} // Namespace System
index 655626b6595073e9b41c11cbc6900c3e01c4535c..8eb351c55cad78fb126f9cce6728ce0bb327cbb0 100644 (file)
@@ -11,7 +11,7 @@ using System.Globalization;
 
 namespace System {
        
-       public struct Byte : IComparable, IFormattable {
+       public struct Byte : IComparable, IFormattable { //, IConvertible {
                public const byte MinValue = 0;
                public const byte MaxValue = 255;
                
@@ -40,21 +40,19 @@ namespace System {
                        return value;
                }
 
-               public TypeCode GetTypeCode ()
+               public static byte Parse (string s)
                {
-                       return TypeCode.Byte;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
-               public static byte Parse (string s)
+               public static byte Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
-               public static byte Parse (string s, IFormatProvider fp)
+               public static byte Parse (string s, NumberStyles style)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, style, null);
                }
 
                public static byte Parse (string s, NumberStyles style, IFormatProvider fp)
@@ -65,21 +63,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -87,5 +81,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+               
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.Byte;
+               }
        }
 }
index e15d0bd121a99d5fbd425b54c36514060bc10d1a..51bb8c31b884081d1db34cfad6bcf5ba69f15dab 100644 (file)
@@ -1,3 +1,49 @@
+2001-07-24  Derek Holden  <dholden@draper.com>
+
+       * Boolean.cs: Formatted to code style standard. Added GetTypeCode
+       which is really an IConvertible defined method.
+
+       * Byte.cs: Added a missing Parse method. Put in Parse and ToString
+       behavior, still need to do the main Parse and ToString.
+
+       * Char.cs: Added a bunch of missing ECMA methods. Commented a
+       specification discrepency. Still didn't any unicode stuff, though
+       every IsFoo(char c) method has an IsFoo(string, index)
+       counterpart, added wrappers for those.
+       
+       * Convert.cs: Fixed NaN/Inf checking and double/float
+       rounding. Added ToType for IConvertible classes
+
+       * Double.cs: Fixed ECMA min and max values. Added IsInfinity /
+       IsNaN methods. Changed Inf/NaN internals.
+
+       * IConvertible.cs: Added comments for using
+       Convert.ToType. Changed return values to draft base values.
+
+       * Int16.cs: Added a missing Parse statement. Put in behavior for
+       overloaded ToString and Parse methods.
+
+       * Int32.cs: Added a missing Parse statement. Put in behavior for
+       overloaded ToString and Parse methods.
+
+       * Int64.cs: Added a missing Parse statement. Put in behavior for
+       overloaded ToString and Parse methods.
+       
+       * Single.cs: Put in ECMA epsilon value. Added IsInfinity / IsNaN
+       methods. Changed Inf/NaN internals.
+
+       * SByte.cs: Added a missing Parse method. Put in Parse and
+       ToString behavior, still need to do the main Parse and ToString.
+
+       * UInt16.cs: Added a missing Parse statement. Put in behavior for
+       overloaded ToString and Parse methods.
+
+       * UInt32.cs: Added a missing Parse statement. Put in behavior for
+       overloaded ToString and Parse methods.
+
+       * UInt64.cs: Added a missing Parse statement. Put in behavior for
+       overloaded ToString and Parse methods.
+       
 2001-07-20  Miguel de Icaza  <miguel@ximian.com>
 
        * MulticastDelegate.cs: New File.
index f0571bb0b0339393bfd2f9fc7eaada1cdfabc37a..284deeeffd53c6e938b0f5907263648e428a2544 100644 (file)
@@ -1,4 +1,3 @@
-// -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 //
 // System.Char.cs
 //
@@ -8,18 +7,25 @@
 // (C) Ximian, Inc.  http://www.ximian.com
 //
 
+// Note about the ToString()'s. ECMA says there's only a ToString() method, 
+// BUT it is just a wrapper for ToString(null). However there is no other ToString
+// in the docs. Turning to the NET framework sdk reveals that there is a 
+// ToString(formatprovider) method, as well as a 'static ToString (char c)' method, 
+// which appears to just be a Convert.ToString(char c) type method. ECMA also
+// doesn't list this class as implementing IFormattable.
+
 using System.Globalization;
 
 namespace System {
        
-       public struct Char : IComparable, IFormattable {
-               public const char MinValue = (char) 0;
+       public struct Char : IComparable { //, IFormattable, IConvertible {
                public const char MaxValue = (char) 0xffff;
+               public const char MinValue = (char) 0;
                
                // VES needs to know about value.  public is workaround
                // so source will compile
                public byte value;
-
+               
                public int CompareTo (object v)
                {
                        if (!(v is System.Byte))
@@ -48,49 +54,251 @@ namespace System {
                        return -1;
                }
 
-               public static double GetNumericValue (string s, int index)
+               public static double GetNumericValue (string str, int index)
                {
-                       /* FIXME: implement me */
-                       return -1;
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return GetNumericValue (str[index]);
+               }
+
+               public static UnicodeCategory GetUnicodeCategory (char c) 
+               { 
+                       // TODO: Implement me
+                       return UnicodeCategory.OtherSymbol;
+               }
+
+               public static UnicodeCategory GetUnicodeCategory (string str, int index) {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return GetUnicodeCategory (str[index]);
                }
 
                public static bool IsControl (char c)
                {
+                       // TODO: Make me Unicode aware
                        return ((c > 1) && (c < 32));
                }
 
+               public static bool IsControl (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsControl (str[index]);
+               }
+               
                public static bool IsDigit (char c)
                {
                        return ((c >= '0') && (c <= '9'));
                }
 
+               public static bool IsDigit (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsDigit (str[index]);
+               }
+
                public static bool IsLetter (char c)
                {
-                       /*
-                        * FIXME: This is broken, it should support
-                        * the various categories in System.Globalization.UnicodeCategory
-                        */
+                       // TODO: Make me Unicode aware
                        return ((c >= 65) && (c <= 126));
                }
+
+               public static bool IsLetter (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsLetter (str[index]);
+               }
+
+               public static bool IsLetterOrDigit (char c)
+               {
+                       // TODO: Implement me
+                       return false;
+               }
+
+               public static bool IsLetterOrDigit (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsLetterOrDigit (str[index]);
+               }
                
-               public TypeCode GetTypeCode ()
+               public static bool IsLower (char c)
                {
-                       return TypeCode.Byte;
+                       // TODO: Implement me
+                       return false;
+               }
+               
+               public static bool IsLower (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsLower (str[index]);
                }
 
-               public static char Parse (string s)
+               public static bool IsNumber (char c)
                {
                        // TODO: Implement me
-                       return (char) 0;
+                       return false;
+               }
+               
+               public static bool IsNumber (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsNumber (str[index]);
                }
 
-               public static char Parse (string s, IFormatProvider fp)
+               public static bool IsPunctuation (char c)
                {
                        // TODO: Implement me
-                       return (char) 0;
+                       return false;
+               }
+               
+               public static bool IsPunctuation (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsPunctuation (str[index]);
+               }
+
+               public static bool IsSeparator (char c)
+               {
+                       // TODO: Implement me
+                       return false;
+               }
+               
+               public static bool IsSeparator (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsSeparator (str[index]);
+               }
+
+               public static bool IsSurrogate (char c)
+               {
+                       // TODO: Implement me
+                       return false;
+               }
+               
+               public static bool IsSurrogate (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsSurrogate (str[index]);
+               }
+
+               public static bool IsSymbol (char c)
+               {
+                       // TODO: Implement me
+                       return false;
+               }
+               
+               public static bool IsSymbol (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsSymbol (str[index]);
+               }
+
+               public static bool IsUpper (char c)
+               {
+                       // TODO: Implement me
+                       return false;
+               }
+               
+               public static bool IsUpper (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsUpper (str[index]);
                }
 
-               public static char Parse (string s, NumberStyles style, IFormatProvider fp)
+               public static bool IsWhiteSpace (char c)
+               {
+                       // TODO: Implement me
+                       return false;
+               }
+               
+               public static bool IsWhiteSpace (string str, int index)
+               {
+                       if (str == null) 
+                               throw new ArgumentNullException ("Str is a null reference");
+                       
+                       if (index < 0 || index >= str.Length)
+                               throw new ArgumentOutOfRangeException
+                               ("The value of index is less than zero, or greater than or equal to the length of str");
+                       
+                       return IsWhiteSpace (str[index]);
+               }
+
+               public static char Parse (string str)
                {
                        // TODO: Implement me
                        return (char) 0;
@@ -98,39 +306,34 @@ namespace System {
 
                public static char ToLower (char c)
                {
-                       // FIXME: make me unicode aware
+                       // TODO: make me unicode aware
                        return (c >= 'A' && c <= 'Z') ? (char) (c + 33) : c;
                }
 
                public static char ToUpper (char c)
                {
-                       // FIXME: make me unicode aware
+                       // TODO: make me unicode aware
                        return (char) ((c >= 'a' && c <= 'z') ? c - 33 : c);
                }
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       // LAMESPEC: ECMA draft lists this as returning ToString (null), 
+                       // However it doesn't list another ToString() method.
+                       return ToString (null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
-               }
-
-               public string ToString (string format)
-               {
-                       // TODO: Implement me.
+                       // LAMESPEC: ECMA draft doesn't say Char implements IFormattable
                        return "";
                }
 
-               public string ToString (string format, IFormatProvider fp)
+               // =========== IConvertible Methods =========== //
+               
+               public TypeCode GetTypeCode ()
                {
-                       // TODO: Implement me.
-                       return "";
-               }
+                       return TypeCode.Byte;
+               }         
        }
 }
index 187cc0c10ffe6f572271195e20116a3fb7bfeba0..ddf1831c5bd932b4b2c31efdb2ec1bd3deada182 100644 (file)
@@ -24,6 +24,8 @@
 // Convert.ToBoolean(byte), or Convert.ToBoolean(byte) calls 
 // byte.ToBoolean(). The first case is what is done here.
 //
+// See http://lists.ximian.com/archives/public/mono-list/2001-July/000525.html
+//
 // There are also conversion functions that are not defined in
 // the ECMA draft, such as there is no bool ToBoolean(DateTime value), 
 // and placing that somewhere won't compile w/ this Convert since the
 // System.Convert doesn't produce any compiler errors, it just throws
 // an InvalidCastException at runtime.
 //
+// Whenever a decimal, double, or single is converted to an integer
+// based type, it is even rounded. This uses Math.Round which only 
+// has Round(decimal) and Round(double), so in the Convert from 
+// single cases the value is passed to Math as a double. This 
+// may not be completely necessary.
+//
 // The .NET Framework SDK lists DBNull as a member of this class
 // as 'public static readonly object DBNull;'. 
 //
 // It should also be decided if all the cast return values should be
 // returned as unchecked or not.
 //
+// All the XML function comments were auto generated which is why they
+// sound someone redundant.
+//
+// TYPE | BOOL BYTE CHAR DT DEC DBL I16 I32 I64 SBYT SNGL STR UI16 UI32 UI64
+// -----+--------------------------------------------------------------------
+// BOOL |   X    X           X   X   X   X   X    X    X   X    X    X    X
+// BYTE |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+// CHAR |        X    X              X   X   X    X        X    X    X    X
+// DT   |                 X                                X
+// DEC  |   X    X           X   X   X   X   X    X    X   X    X    X    X
+// DBL  |   X    X           X   X   X   X   X    X    X   X    X    X    X
+// I16  |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+// I32  |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+// I64  |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+// SBYT |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+// SNGL |   X    X           X   X   X   X   X    X    X   X    X    X    X
+// STR  |   X    X    X   X  X   X   X   X   X    X    X   X    X    X    X
+// UI16 |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+// UI32 |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+// UI64 |   X    X    X      X   X   X   X   X    X    X   X    X    X    X
+//
 
 namespace System {
-    
-    /// <summary>
-    /// Class to convert between data types.</summary>
-    public sealed class Convert {
-       
-       // ========== Boolean Conversions ========== //
-       
-       public static bool ToBoolean(bool value) { 
-           return value; 
-       }
-       
-       public static bool ToBoolean(byte value) { 
-           return (value != 0); 
-       }
-
-       public static bool ToBoolean(decimal value) { 
-           return (value != 0M); 
-       }
-
-       public static bool ToBoolean(double value) { 
-           return (value != 0); 
-       }
-
-       public static bool ToBoolean(float value) { 
-           return (value != 0f); 
-       }
-
-       public static bool ToBoolean(int value) { 
-           return (value != 0); 
-       }
-
-       public static bool ToBoolean(long value) { 
-           return (value != 0); 
-       }
-
-       public static bool ToBoolean(sbyte value) { 
-           return (value != 0); 
-       }
-       
-       public static bool ToBoolean(short value) { 
-           return (value != 0); 
-       }
-
-       public static bool ToBoolean(string value) {
-           return Boolean.Parse(value);
-       }
-       
-       public static bool ToBoolean(uint value) { 
-           return (value != 0);
-       }
-
-       public static bool ToBoolean(ulong value) { 
-           return (value != 0); 
-       }
-
-       public static bool ToBoolean(ushort value) { 
-           return (value != 0); 
-       }
-
-       // ========== Byte Conversions ========== //
-       
-       public static byte ToByte(bool value) { 
-           return (byte)(value ? 1 : 0); 
-       }
-       
-       public static byte ToByte(byte value) { 
-           return value; 
-       }
-
-       public static byte ToByte(char value) { 
-           if(value > Byte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue");
-
-           return (byte)value;
-       }
-       
-       public static byte ToByte(decimal value) { 
-           if(value > Byte.MaxValue || value < Byte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
-           
-           return (byte)value;
-       }
-       
-       public static byte ToByte(double value) { 
-           if(value > Byte.MaxValue || value < Byte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
-          
-           // This and the float version of ToByte are the only ones
-           // the spec listed as checking for .NaN and Infinity overflow
-           if(value == Double.NaN || value == Double.PositiveInfinity ||
-              value == Double.NegativeInfinity)
-               throw new OverflowException
-                   ("Value is equal to Double.NaN, Double.PositiveInfinity, or Double.NegativeInfinity");
-
-           return (byte)value;
-       }
-
-       public static byte ToByte(float value) { 
-           if(value > Byte.MaxValue || value < Byte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue or less than Byte.Minalue");
-
-           // This and the double version of ToByte are the only ones
-           // the spec listed as checking for .NaN and Infinity overflow
-           if(value == Single.NaN || value == Single.PositiveInfinity ||
-              value == Single.NegativeInfinity)
-               throw new OverflowException
-                   ("Value is equal to Single.NaN, Single.PositiveInfinity, or Single.NegativeInfinity");
-
-           return (byte)value;
-       }
-
-       public static byte ToByte(int value) { 
-           if(value > Byte.MaxValue || value < Byte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
-           
-           return (byte)value; 
-       }
-
-       public static byte ToByte(long value) { 
-           if(value > Byte.MaxValue || value < Byte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
-           
-           return (byte)value;
-       }
-
-       public static byte ToByte(sbyte value) { 
-           if(value < Byte.MinValue)
-               throw new OverflowException
-                   ("Value is less than Byte.MinValue");
-           
-           return (byte)value;
-       }
-       
-       public static byte ToByte(short value) { 
-           if(value > Byte.MaxValue || value < Byte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
-           
-           return (byte)value; 
-       }
-
-       public static byte ToByte(string value) {
-           return Byte.Parse(value);
-       }
-
-       public static byte ToByte(string value, IFormatProvider provider) {
-           return Byte.Parse(value, provider);
-       }
-       
-       public static byte ToByte(uint value) { 
-           if(value > Byte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue");
-
-           return (byte)value;
-       }
-
-       public static byte ToByte(ulong value) { 
-           if(value > Byte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue");
-
-           return (byte)value;
-       }
-
-       public static byte ToByte(ushort value) { 
-           if(value > Byte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than Byte.MaxValue");
-
-           return (byte)value;
-       }
-
-       // ========== Char Conversions ========== //
-       
-       public static char ToChar(byte value) { 
-           return (char)value;
-       }
-
-       public static char ToChar(char value) { 
-           return value;
-       }
-
-       public static char ToChar(int value) { 
-           if(value > Char.MaxValue || value < Char.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Char.MaxValue or less than Char.MinValue");
-           
-           return (char)value; 
-       }
-
-       public static char ToChar(long value) { 
-           if(value > Char.MaxValue || value < Char.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Char.MaxValue or less than Char.MinValue");
-           
-           return (char)value; 
-       }
-
-       public static char ToChar(sbyte value) { 
-           if(value < Char.MinValue)
-               throw new OverflowException
-                   ("Value is less than Char.MinValue");
-           
-           return (char)value; 
-       }
-       
-       public static char ToChar(short value) { 
-           if(value < Char.MinValue)
-               throw new OverflowException
-                   ("Value is less than Char.MinValue");
-           
-           return (char)value;  
-       }
-
-       public static char ToChar(string value) {
-           return Char.Parse(value);
-       }
-       
-       public static char ToChar(uint value) { 
-           if(value > Char.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than Char.MaxValue");
-           
-           return (char)value;  
-       }
-
-       public static char ToChar(ulong value) { 
-           if(value > Char.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than Char.MaxValue");
-           
-           return (char)value;  
-       }
-
-       public static char ToChar(ushort value) { 
-           if(value > Char.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than Char.MaxValue");
-           
-           return (char)value;  
-       }
-
-       // ========== DateTime Conversions ========== //
-       
-       public static DateTime ToDateTime(string value) { 
-           return DateTime.Parse(value);
-       }
-       
-       public static DateTime ToDateTime(string value, IFormatProvider provider) {
-           return DateTime.Parse(value, provider);
-       }
-
-       // ========== Decimal Conversions ========== //
-       
-       public static decimal ToDecimal(bool value) { 
-           return value ? 1 : 0; 
-       }
-       
-       public static decimal ToDecimal(byte value) { 
-           return (decimal)value; 
-       }
-       
-       public static decimal ToDecimal(decimal value) { 
-           return value; 
-       }
-
-       public static decimal ToDecimal(double value) { 
-           if(value > (double)Decimal.MaxValue || value < (double)Decimal.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Decimal.MaxValue or less than Decimal.MinValue");
-
-           return (decimal)value; 
-       }
-
-       public static decimal ToDecimal(float value) { 
-           if(value > (double)Decimal.MaxValue || value < (double)Decimal.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Decimal.MaxValue or less than Decimal.MinValue");
-
-           return (decimal)value; 
-       }
-
-       public static decimal ToDecimal(int value) { 
-           return (decimal)value; 
-       }
-       
-       public static decimal ToDecimal(long value) { 
-           return (decimal)value; 
-       }
-
-       public static decimal ToDecimal(sbyte value) { 
-           return (decimal)value;  
-       }
-       
-       public static decimal ToDecimal(short value) { 
-           return (decimal)value; 
-       }
-
-       public static decimal ToDecimal(string value) {
-           return Decimal.Parse(value);
-       }
-
-       public static decimal ToDecimal(string value, IFormatProvider provider) {
-           return Decimal.Parse(value, provider);
-       }
-       
-       public static decimal ToDecimal(uint value) { 
-           return (decimal)value; 
-       }
-
-       public static decimal ToDecimal(ulong value) { 
-           return (decimal)value; 
-       }
-
-       public static decimal ToDecimal(ushort value) { 
-           return (decimal)value; 
-       }
-
-       // ========== Double Conversions ========== //
-       
-       public static double ToDouble(bool value) { 
-           return value ? 1 : 0; 
-       }
-       
-       public static double ToDouble(byte value) { 
-           return (double)value; 
-       }
-       
-       public static double ToDouble(decimal value) { 
-           return (double)value; 
-       }
-
-       public static double ToDouble(double value) { 
-           return value; 
-       }
-
-       public static double ToDouble(float value) { 
-           return (double)value; 
-       }
-
-       public static double ToDouble(int value) { 
-           return (double)value; 
-       }
-       
-       public static double ToDouble(long value) { 
-           return (double)value; 
-       }
-
-       public static double ToDouble(sbyte value) { 
-           return (double)value;  
-       }
-       
-       public static double ToDouble(short value) { 
-           return (double)value; 
-       }
-
-       public static double ToDouble(string value) {
-           return Double.Parse(value);
-       }
-
-       public static double ToDouble(string value, IFormatProvider provider) {
-           return Double.Parse(value, provider);
-       }
-       
-       public static double ToDouble(uint value) { 
-           return (double)value; 
-       }
-
-       public static double ToDouble(ulong value) { 
-           return (double)value; 
-       }
-
-       public static double ToDouble(ushort value) { 
-           return (double)value; 
-       }
-
-       // ========== Int16 Conversions ========== //
-
-       public static short ToInt16(bool value) { 
-           return (short)(value ? 1 : 0); 
-       }
-       
-       public static short ToInt16(byte value) { 
-           return (short)value; 
-       }
-
-       public static short ToInt16(char value) { 
-           if(value > Int16.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue");
-
-           return (short)value; 
-       }
-       
-       public static short ToInt16(decimal value) { 
-           if(value > Int16.MaxValue || value < Int16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
-           
-           return (short)value;            
-       }
-
-       public static short ToInt16(double value) { 
-           if(value > Int16.MaxValue || value < Int16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
-           
-           return (short)value;            
-       }
+  
+       public sealed class Convert {
+       
+               // ========== Boolean Conversions ========== //
+       
+               public static bool ToBoolean (bool value) 
+               { 
+                       return value; 
+               }
+
+               public static bool ToBoolean (byte value) 
+               { 
+                       return (value != 0); 
+               }
+
+               public static bool ToBoolean (decimal value) 
+               { 
+                       return (value != 0M); 
+               }
+
+               public static bool ToBoolean (double value) 
+               { 
+                       return (value != 0); 
+               }
+
+               public static bool ToBoolean (float value) 
+               { 
+                       return (value != 0f); 
+               }
+
+               public static bool ToBoolean (int value) 
+               { 
+                       return (value != 0); 
+               }
+
+               public static bool ToBoolean (long value) 
+               { 
+                       return (value != 0); 
+               }
+
+               public static bool ToBoolean (sbyte value) 
+               { 
+                       return (value != 0); 
+               }
+       
+               public static bool ToBoolean (short value) 
+               { 
+                       return (value != 0); 
+               }
+
+               public static bool ToBoolean (string value) 
+               {
+                       return Boolean.Parse (value);
+               }
+       
+               public static bool ToBoolean (uint value) 
+               { 
+                       return (value != 0);
+               }
+
+               public static bool ToBoolean (ulong value) 
+               { 
+                       return (value != 0); 
+               }
+
+               public static bool ToBoolean (ushort value) 
+               { 
+                       return (value != 0); 
+               }
+
+               // ========== Byte Conversions ========== //
+       
+               public static byte ToByte (bool value) 
+               { 
+                       return (byte)(value ? 1 : 0); 
+               }
+       
+               public static byte ToByte (byte value) 
+               { 
+                       return value; 
+               }
+
+               public static byte ToByte (char value) 
+               { 
+                       if (value > Byte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue");
+
+                       return (byte)value;
+               }
+       
+               public static byte ToByte (decimal value) 
+               { 
+                       if (value > Byte.MaxValue || value < Byte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (byte)(Math.Round (value));
+               }
+       
+               public static byte ToByte (double value) 
+               { 
+                       if (value > Byte.MaxValue || value < Byte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
+         
+                       // This and the float version of ToByte are the only ones
+                       // the spec listed as checking for .NaN and Infinity overflow
+                       if (Double.IsNaN(value) || Double.IsInfinity(value))
+                               throw new OverflowException
+                               ("Value is equal to Double.NaN, Double.PositiveInfinity, or Double.NegativeInfinity");
+
+                       // Returned Even-Rounded
+                       return (byte)(Math.Round (value));
+               }
+
+               public static byte ToByte (float value) 
+               { 
+                       if (value > Byte.MaxValue || value < Byte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue or less than Byte.Minalue");
+
+                       // This and the double version of ToByte are the only ones
+                       // the spec listed as checking for .NaN and Infinity overflow
+                       if (Single.IsNaN(value) || Single.IsInfinity(value))
+                               throw new OverflowException
+                               ("Value is equal to Single.NaN, Single.PositiveInfinity, or Single.NegativeInfinity");
+         
+                       // Returned Even-Rounded, pass it as a double, could have this
+                       // method just call Convert.ToByte ( (double)value)
+                       return (byte)(Math.Round ( (double)value));
+               }
+
+               public static byte ToByte (int value) 
+               { 
+                       if (value > Byte.MaxValue || value < Byte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
+         
+                       return (byte)value; 
+               }
+
+               public static byte ToByte (long value) 
+               { 
+                       if (value > Byte.MaxValue || value < Byte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
+         
+                       return (byte)value;
+               }
+
+               public static byte ToByte (sbyte value) 
+               { 
+                       if (value < Byte.MinValue)
+                               throw new OverflowException
+                               ("Value is less than Byte.MinValue");
+         
+                       return (byte)value;
+               }
+       
+               public static byte ToByte (short value) 
+               { 
+                       if (value > Byte.MaxValue || value < Byte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue or less than Byte.MinValue");
+         
+                       return (byte)value; 
+               }
+
+               public static byte ToByte (string value) 
+               {
+                       return Byte.Parse (value);
+               }
+
+               public static byte ToByte (string value, IFormatProvider provider) 
+               {
+                       return Byte.Parse (value, provider);
+               }
+       
+               public static byte ToByte (uint value) 
+               { 
+                       if (value > Byte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue");
+
+                       return (byte)value;
+               }
+
+               public static byte ToByte (ulong value) 
+               { 
+                       if (value > Byte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue");
+
+                       return (byte)value;
+               }
+
+               public static byte ToByte (ushort value) 
+               { 
+                       if (value > Byte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than Byte.MaxValue");
+
+                       return (byte)value;
+               }
+
+               // ========== Char Conversions ========== //
+       
+               public static char ToChar (byte value) 
+               { 
+                       return (char)value;
+               }
+
+               public static char ToChar (char value) 
+               { 
+                       return value;
+               }
+
+               public static char ToChar (int value) 
+               { 
+                       if (value > Char.MaxValue || value < Char.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Char.MaxValue or less than Char.MinValue");
+         
+                       return (char)value; 
+               }
+
+               public static char ToChar (long value) 
+               { 
+                       if (value > Char.MaxValue || value < Char.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Char.MaxValue or less than Char.MinValue");
+         
+                       return (char)value; 
+               }
+
+               public static char ToChar (sbyte value) 
+               { 
+                       if (value < Char.MinValue)
+                               throw new OverflowException
+                               ("Value is less than Char.MinValue");
+         
+                       return (char)value; 
+               }
+       
+               public static char ToChar (short value) 
+               { 
+                       if (value < Char.MinValue)
+                               throw new OverflowException
+                               ("Value is less than Char.MinValue");
+         
+                       return (char)value; 
+               }
+
+               public static char ToChar (string value) 
+               {
+                       return Char.Parse (value);
+               }
+       
+               public static char ToChar (uint value) 
+               { 
+                       if (value > Char.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than Char.MaxValue");
+         
+                       return (char)value; 
+               }
+
+               public static char ToChar (ulong value) 
+               { 
+                       if (value > Char.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than Char.MaxValue");
+         
+                       return (char)value; 
+               }
+
+               public static char ToChar (ushort value) 
+               { 
+                       if (value > Char.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than Char.MaxValue");
+         
+                       return (char)value; 
+               }
+
+               // ========== DateTime Conversions ========== //
+       
+               public static DateTime ToDateTime (string value) 
+               { 
+                       return DateTime.Parse (value);
+               }
+       
+               public static DateTime ToDateTime (string value, IFormatProvider provider) 
+               {
+                       return DateTime.Parse (value, provider);
+               }
+
+               // ========== Decimal Conversions ========== //
+       
+               public static decimal ToDecimal (bool value) 
+               { 
+                       return value ? 1 : 0; 
+               }
+       
+               public static decimal ToDecimal (byte value) 
+               { 
+                       return (decimal)value; 
+               }
+       
+               public static decimal ToDecimal (decimal value) 
+               { 
+                       return value; 
+               }
+
+               public static decimal ToDecimal (double value) 
+               { 
+                       if (value > (double)Decimal.MaxValue || value < (double)Decimal.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Decimal.MaxValue or less than Decimal.MinValue");
+
+                       return (decimal)value; 
+               }
+
+               public static decimal ToDecimal (float value) 
+               { 
+                       if (value > (double)Decimal.MaxValue || value < (double)Decimal.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Decimal.MaxValue or less than Decimal.MinValue");
+
+                       return (decimal)value; 
+               }
+
+               public static decimal ToDecimal (int value) 
+               { 
+                       return (decimal)value; 
+               }
+       
+               public static decimal ToDecimal (long value) 
+               { 
+                       return (decimal)value; 
+               }
+
+               public static decimal ToDecimal (sbyte value) 
+               { 
+                       return (decimal)value; 
+               }
+       
+               public static decimal ToDecimal (short value) 
+               { 
+                       return (decimal)value; 
+               }
+
+               public static decimal ToDecimal (string value) 
+               {
+                       return Decimal.Parse (value);
+               }
+
+               public static decimal ToDecimal (string value, IFormatProvider provider) 
+               {
+                       return Decimal.Parse (value, provider);
+               }
+       
+               public static decimal ToDecimal (uint value) 
+               { 
+                       return (decimal)value; 
+               }
+
+               public static decimal ToDecimal (ulong value) 
+               { 
+                       return (decimal)value; 
+               }
+
+               public static decimal ToDecimal (ushort value) 
+               { 
+                       return (decimal)value; 
+               }
+
+               // ========== Double Conversions ========== //
+       
+               public static double ToDouble (bool value) 
+               { 
+                       return value ? 1 : 0; 
+               }
+       
+               public static double ToDouble (byte value) 
+               { 
+                       return (double)value; 
+               }
+       
+               public static double ToDouble (decimal value) 
+               { 
+                       return (double)value; 
+               }
+
+               public static double ToDouble (double value) 
+               { 
+                       return value; 
+               }
+
+               public static double ToDouble (float value) 
+               { 
+                       return (double)value; 
+               }
+
+               public static double ToDouble (int value) 
+               { 
+                       return (double)value; 
+               }
+       
+               public static double ToDouble (long value) 
+               { 
+                       return (double)value; 
+               }
+
+               public static double ToDouble (sbyte value) 
+               { 
+                       return (double)value; 
+               }
+       
+               public static double ToDouble (short value) 
+               { 
+                       return (double)value; 
+               }
+
+               public static double ToDouble (string value) 
+               {
+                       return Double.Parse (value);
+               }
+
+               public static double ToDouble (string value, IFormatProvider provider) 
+               {
+                       return Double.Parse (value, provider);
+               }
+       
+               public static double ToDouble (uint value) 
+               { 
+                       return (double)value; 
+               }
+
+               public static double ToDouble (ulong value) 
+               { 
+                       return (double)value; 
+               }
+
+               public static double ToDouble (ushort value) 
+               { 
+                       return (double)value; 
+               }
+
+               // ========== Int16 Conversions ========== //
+
+               public static short ToInt16 (bool value) 
+               { 
+                       return (short)(value ? 1 : 0); 
+               }
+       
+               public static short ToInt16 (byte value) 
+               { 
+                       return (short)value; 
+               }
+
+               public static short ToInt16 (char value) 
+               { 
+                       if (value > Int16.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue");
+
+                       return (short)value; 
+               }
+       
+               public static short ToInt16 (decimal value) 
+               { 
+                       if (value > Int16.MaxValue || value < Int16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (short)(Math.Round (value));       
+               }
+
+               public static short ToInt16 (double value) 
+               { 
+                       if (value > Int16.MaxValue || value < Int16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (short)(Math.Round (value));       
+               }
  
-       public static short ToInt16(float value) { 
-           if(value > Int16.MaxValue || value < Int16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
-           
-           return (short)value;
-       }
-
-       public static short ToInt16(int value) { 
-           if(value > Int16.MaxValue || value < Int16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
-
-           return (short)value; 
-       }
-       
-       public static short ToInt16(long value) { 
-           if(value > Int16.MaxValue || value < Int16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
-
-           return (short)value; 
-       }
-
-       public static short ToInt16(sbyte value) { 
-           return (short)value;  
-       }
-       
-       public static short ToInt16(short value) { 
-           return value; 
-       }
-
-       public static short ToInt16(string value) {
-           return Int16.Parse(value);
-       }
-
-       public static short ToInt16(string value, IFormatProvider provider) {
-           return Int16.Parse(value, provider);
-       }
-       
-       public static short ToInt16(uint value) { 
-           if(value > Int16.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue");
-
-           return (short)value; 
-       }
-
-       public static short ToInt16(ulong value) { 
-           if(value > (ulong)Int16.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue");
-
-           return (short)value; 
-       }
-
-       public static short ToInt16(ushort value) { 
-           if(value > Int16.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than Int16.MaxValue");
-
-           return (short)value; 
-       }
-
-       // ========== Int32 Conversions ========== //
-
-       public static int ToInt32(bool value) { 
-           return value ? 1 : 0; 
-       }
-       
-       public static int ToInt32(byte value) { 
-           return (int)value; 
-       }
-
-       public static int ToInt32(char value) { 
-           return (int)value; 
-       }
-       
-       public static int ToInt32(decimal value) { 
-           if(value > Int32.MaxValue || value < Int32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
-           
-           return (int)value;      
-       }
-
-       public static int ToInt32(double value) { 
-           if(value > Int32.MaxValue || value < Int32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
-           
-           return (int)value;      
-       }
+               public static short ToInt16 (float value) 
+               { 
+                       if (value > Int16.MaxValue || value < Int16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
+         
+                       // Returned Even-Rounded, use Math.Round pass as a double.
+                       return (short)Math.Round ( (double)value);
+               }
+
+               public static short ToInt16 (int value) 
+               { 
+                       if (value > Int16.MaxValue || value < Int16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
+
+                       return (short)value; 
+               }
+       
+               public static short ToInt16 (long value) 
+               { 
+                       if (value > Int16.MaxValue || value < Int16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue or less than Int16.MinValue");
+
+                       return (short)value; 
+               }
+
+               public static short ToInt16 (sbyte value) 
+               { 
+                       return (short)value; 
+               }
+       
+               public static short ToInt16 (short value) 
+               { 
+                       return value; 
+               }
+
+               public static short ToInt16 (string value) 
+               {
+                       return Int16.Parse (value);
+               }
+
+               public static short ToInt16 (string value, IFormatProvider provider) 
+               {
+                       return Int16.Parse (value, provider);
+               }
+       
+               public static short ToInt16 (uint value) 
+               { 
+                       if (value > Int16.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue");
+
+                       return (short)value; 
+               }
+
+               public static short ToInt16 (ulong value) 
+               { 
+                       if (value > (ulong)Int16.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue");
+
+                       return (short)value; 
+               }
+
+               public static short ToInt16 (ushort value) 
+               { 
+                       if (value > Int16.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int16.MaxValue");
+
+                       return (short)value; 
+               }
+
+               // ========== Int32 Conversions ========== //
+
+               public static int ToInt32 (bool value) 
+               { 
+                       return value ? 1 : 0; 
+               }
+       
+               public static int ToInt32 (byte value) 
+               { 
+                       return (int)value; 
+               }
+
+               public static int ToInt32 (char value) 
+               { 
+                       return (int)value; 
+               }
+       
+               public static int ToInt32 (decimal value) 
+               { 
+                       if (value > Int32.MaxValue || value < Int32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
+
+                       // Returned Even-Rounded
+                       return (int)(Math.Round (value));         
+               }
+
+               public static int ToInt32 (double value) 
+               { 
+                       if (value > Int32.MaxValue || value < Int32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (int)(Math.Round (value));         
+               }
  
-       public static int ToInt32(float value) { 
-           if(value > Int32.MaxValue || value < Int32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
-           
-           return (int)value;
-       }
-
-       public static int ToInt32(int value) { 
-           return value; 
-       }
-       
-       public static int ToInt32(long value) { 
-           if(value > Int32.MaxValue || value < Int32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
-
-           return (int)value; 
-       }
-
-       public static int ToInt32(sbyte value) { 
-           return (int)value;  
-       }
-       
-       public static int ToInt32(short value) { 
-           return (int)value; 
-       }
-
-       public static int ToInt32(string value) {
-           return Int32.Parse(value);
-       }
-
-       public static int ToInt32(string value, IFormatProvider provider) {
-           return Int32.Parse(value, provider);
-       }
-       
-       public static int ToInt32(uint value) { 
-           if(value > Int32.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than Int32.MaxValue");
-
-           return (int)value; 
-       }
-
-       public static int ToInt32(ulong value) { 
-           if(value > Int32.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than Int32.MaxValue");
-
-           return (int)value; 
-       }
-
-       public static int ToInt32(ushort value) { 
-           return (int)value; 
-       }
-
-       // ========== Int64 Conversions ========== //
-
-       public static long ToInt64(bool value) { 
-           return value ? 1 : 0; 
-       }
-       
-       public static long ToInt64(byte value) { 
-           return (long)value; 
-       }
-
-       public static long ToInt64(char value) { 
-           return (long)value; 
-       }
-       
-       public static long ToInt64(decimal value) { 
-           if(value > Int64.MaxValue || value < Int64.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int64.MaxValue or less than Int64.MinValue");
-           
-           return (long)value;     
-       }
-
-       public static long ToInt64(double value) { 
-           if(value > Int64.MaxValue || value < Int64.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int64.MaxValue or less than Int64.MinValue");
-           
-           return (long)value;     
-       }
+               public static int ToInt32 (float value) 
+               { 
+                       if (value > Int32.MaxValue || value < Int32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
+         
+                       // Returned Even-Rounded, pass as a double, could just call
+                       // Convert.ToInt32 ( (double)value);
+                       return (int)(Math.Round ( (double)value));
+               }
+
+               public static int ToInt32 (int value) 
+               { 
+                       return value; 
+               }
+       
+               public static int ToInt32 (long value) 
+               { 
+                       if (value > Int32.MaxValue || value < Int32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int32.MaxValue or less than Int32.MinValue");
+
+                       return (int)value; 
+               }
+
+               public static int ToInt32 (sbyte value) 
+               { 
+                       return (int)value; 
+               }
+       
+               public static int ToInt32 (short value) 
+               { 
+                       return (int)value; 
+               }
+
+               public static int ToInt32 (string value) 
+               {
+                       return Int32.Parse (value);
+               }
+
+               public static int ToInt32 (string value, IFormatProvider provider) 
+               {
+                       return Int32.Parse (value, provider);
+               }
+       
+               public static int ToInt32 (uint value) 
+               { 
+                       if (value > Int32.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int32.MaxValue");
+
+                       return (int)value; 
+               }
+
+               public static int ToInt32 (ulong value) 
+               { 
+                       if (value > Int32.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int32.MaxValue");
+
+                       return (int)value; 
+               }
+
+               public static int ToInt32 (ushort value) 
+               { 
+                       return (int)value; 
+               }
+
+               // ========== Int64 Conversions ========== //
+
+               public static long ToInt64 (bool value) 
+               { 
+                       return value ? 1 : 0; 
+               }
+       
+               public static long ToInt64 (byte value) 
+               { 
+                       return (long)value; 
+               }
+
+               public static long ToInt64 (char value) 
+               { 
+                       return (long)value; 
+               }
+       
+               public static long ToInt64 (decimal value) 
+               { 
+                       if (value > Int64.MaxValue || value < Int64.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int64.MaxValue or less than Int64.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (long)(Math.Round (value));        
+               }
+
+               public static long ToInt64 (double value) 
+               { 
+                       if (value > Int64.MaxValue || value < Int64.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int64.MaxValue or less than Int64.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (long)(Math.Round (value));        
+               }
  
-       public static long ToInt64(float value) { 
-           if(value > Int64.MaxValue || value < Int64.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than Int64.MaxValue or less than Int64.MinValue");
-           
-           return (long)value;
-       }
-
-       public static long ToInt64(int value) { 
-           return (long)value; 
-       }
-       
-       public static long ToInt64(long value) { 
-           return value; 
-       }
-
-       public static long ToInt64(sbyte value) { 
-           return (long)value;  
-       }
-       
-       public static long ToInt64(short value) { 
-           return (long)value; 
-       }
-
-       public static long ToInt64(string value) {
-           return Int64.Parse(value);
-       }
-
-       public static long ToInt64(string value, IFormatProvider provider) {
-           return Int64.Parse(value, provider);
-       }
-       
-       public static long ToInt64(uint value) { 
-           return (long)value; 
-       }
-
-       public static long ToInt64(ulong value) { 
-           if(value > Int64.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than Int64.MaxValue");
-
-           return (long)value; 
-       }
-
-       public static long ToInt64(ushort value) { 
-           return (long)value; 
-       }
-
-       // ========== SByte Conversions ========== //
-       
-       public static sbyte ToSByte(bool value) { 
-           return (sbyte)(value ? 1 : 0); 
-       }
-       
-       public static sbyte ToSByte(byte value) { 
-           if(value > SByte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue");
-
-           return (sbyte)value; 
-       }
-
-       public static sbyte ToSByte(char value) { 
-           if(value > SByte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue");
-
-           return (sbyte)value;
-       }
-       
-       public static sbyte ToSByte(decimal value) { 
-           if(value > SByte.MaxValue || value < SByte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
-           
-           return (sbyte)value;
-       }
-       
-       public static sbyte ToSByte(double value) { 
-           if(value > SByte.MaxValue || value < SByte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
-
-           return (sbyte)value;
-       }
-
-       public static sbyte ToSByte(float value) { 
-           if(value > SByte.MaxValue || value < SByte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue or less than SByte.Minalue");
-
-           return (sbyte)value;
-       }
-
-       public static sbyte ToSByte(int value) { 
-           if(value > SByte.MaxValue || value < SByte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
-           
-           return (sbyte)value; 
-       }
-
-       public static sbyte ToSByte(long value) { 
-           if(value > SByte.MaxValue || value < SByte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
-           
-           return (sbyte)value;
-       }
-
-       public static sbyte ToSByte(sbyte value) { 
-           return value;
-       }
-       
-       public static sbyte ToSByte(short value) { 
-           if(value > SByte.MaxValue || value < SByte.MinValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
-           
-           return (sbyte)value; 
-       }
-
-       public static sbyte ToSByte(string value) {
-           return SByte.Parse(value);
-       }
-
-       public static sbyte ToSByte(string value, IFormatProvider provider) {
-           return SByte.Parse(value, provider);
-       }
-       
-       public static sbyte ToSByte(uint value) { 
-           if(value > SByte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue");
-
-           return (sbyte)value;
-       }
-
-       public static sbyte ToSByte(ulong value) { 
-           if(value > (ulong)SByte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue");
-
-           return (sbyte)value;
-       }
-
-       public static sbyte ToSByte(ushort value) { 
-           if(value > SByte.MaxValue)
-               throw new OverflowException
-                   ("Value is greater than SByte.MaxValue");
-
-           return (sbyte)value;
-       }
-
-       // ========== Single Conversions ========== //
-       
-       public static float ToSingle(bool value) { 
-           return value ? 1 : 0; 
-       }
-       
-       public static float ToSingle(byte value) { 
-           return (float)value; 
-       }
-       
-       public static float ToSingle(decimal value) { 
-           return (float)value; 
-       }
-
-       public static float ToSingle(double value) { 
-           if(value > Single.MaxValue || value < Single.MinValue)
-               throw new OverflowException
-                   ("Value is greater than Single.MaxValue or less than Single.MinValue");
-
-           return (float)value; 
-       }
-       
-       public static float ToSingle(float value) { 
-           return value; 
-       }
-
-       public static float ToSingle(int value) { 
-           return (float)value; 
-       }
-       
-       public static float ToSingle(long value) { 
-           return (float)value; 
-       }
-
-       public static float ToSingle(sbyte value) { 
-           return (float)value;  
-       }
-       
-       public static float ToSingle(short value) { 
-           return (float)value; 
-       }
-
-       public static float ToSingle(string value) {
-           return Single.Parse(value);
-       }
-
-       public static float ToSingle(string value, IFormatProvider provider) {
-           return Single.Parse(value, provider);
-       }
-       
-       public static float ToSingle(uint value) { 
-           return (float)value; 
-       }
-
-       public static float ToSingle(ulong value) { 
-           return (float)value; 
-       }
-
-       public static float ToSingle(ushort value) { 
-           return (float)value; 
-       }
-
-       // ========== String Conversions ========== //
-       
-       public static string ToString(bool value) { 
-           return value.ToString(); 
-       }
-       
-       public static string ToString(byte value) { 
-           return value.ToString(); 
-       }
-       
-       public static string ToString(byte value, IFormatProvider provider) {
-           return value.ToString(provider); 
-       }
-
-       public static string ToString(char value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(DateTime value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(DateTime value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-
-       public static string ToString(decimal value) {
-           return value.ToString();
-       }
-
-       public static string ToString(decimal value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-       
-       public static string ToString(double value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(double value, IFormatProvider provider) { 
-           return value.ToString(provider);
-       }
-       
-       public static string ToString(float value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(float value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-
-       public static string ToString(int value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(int value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-       
-       public static string ToString(long value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(long value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-
-       public static string ToString(sbyte value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(sbyte value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-       
-       public static string ToString(short value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(short value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-
-       public static string ToString(string value) {
-           return value;
-       }
-
-       public static string ToString(uint value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(uint value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-
-       public static string ToString(ulong value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(ulong value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-
-       public static string ToString(ushort value) { 
-           return value.ToString(); 
-       }
-
-       public static string ToString(ushort value, IFormatProvider provider) { 
-           return value.ToString(provider); 
-       }
-
-       // ========== UInt16 Conversions ========== //
-
-       public static ushort ToUInt16(bool value) { 
-           return (ushort)(value ? 1 : 0); 
-       }
-       
-       public static ushort ToUInt16(byte value) { 
-           return (ushort)value; 
-       }
-
-       public static ushort ToUInt16(char value) { 
-           return (ushort)value; 
-       }
-       
-       public static ushort ToUInt16(decimal value) { 
-           if(value > UInt16.MaxValue || value < UInt16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
-           
-           return (ushort)value;           
-       }
-
-       public static ushort ToUInt16(double value) { 
-           if(value > UInt16.MaxValue || value < UInt16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
-           
-           return (ushort)value;           
-       }
+               public static long ToInt64 (float value) 
+               { 
+                       if (value > Int64.MaxValue || value < Int64.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int64.MaxValue or less than Int64.MinValue");
+         
+                       // Returned Even-Rounded, pass to Math as a double, could
+                       // just call Convert.ToInt64 ( (double)value);
+                       return (long)(Math.Round ( (double)value));
+               }
+
+               public static long ToInt64 (int value) 
+               { 
+                       return (long)value; 
+               }
+       
+               public static long ToInt64 (long value) 
+               { 
+                       return value; 
+               }
+
+               public static long ToInt64 (sbyte value) 
+               { 
+                       return (long)value; 
+               }
+       
+               public static long ToInt64 (short value) 
+               { 
+                       return (long)value; 
+               }
+
+               public static long ToInt64 (string value) 
+               {
+                       return Int64.Parse (value);
+               }
+
+               public static long ToInt64 (string value, IFormatProvider provider) 
+               {
+                       return Int64.Parse (value, provider);
+               }
+       
+               public static long ToInt64 (uint value) 
+               { 
+                       return (long)value; 
+               }
+
+               public static long ToInt64 (ulong value) 
+               { 
+                       if (value > Int64.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than Int64.MaxValue");
+
+                       return (long)value; 
+               }
+
+               public static long ToInt64 (ushort value) 
+               { 
+                       return (long)value; 
+               }
+
+               // ========== SByte Conversions ========== //
+       
+               public static sbyte ToSByte (bool value) 
+               { 
+                       return (sbyte)(value ? 1 : 0); 
+               }
+       
+               public static sbyte ToSByte (byte value) 
+               { 
+                       if (value > SByte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue");
+
+                       return (sbyte)value; 
+               }
+
+               public static sbyte ToSByte (char value) 
+               { 
+                       if (value > SByte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue");
+
+                       return (sbyte)value;
+               }
+       
+               public static sbyte ToSByte (decimal value) 
+               { 
+                       if (value > SByte.MaxValue || value < SByte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (sbyte)(Math.Round (value));
+               }
+       
+               public static sbyte ToSByte (double value) 
+               { 
+                       if (value > SByte.MaxValue || value < SByte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
+
+                       // Returned Even-Rounded
+                       return (sbyte)(Math.Round (value));
+               }
+
+               public static sbyte ToSByte (float value) 
+               { 
+                       if (value > SByte.MaxValue || value < SByte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue or less than SByte.Minalue");
+
+                       // Returned Even-Rounded, pass as double to Math
+                       return (sbyte)(Math.Round ( (double)value));
+               }
+
+               public static sbyte ToSByte (int value) 
+               { 
+                       if (value > SByte.MaxValue || value < SByte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
+         
+                       return (sbyte)value; 
+               }
+
+               public static sbyte ToSByte (long value) 
+               { 
+                       if (value > SByte.MaxValue || value < SByte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
+         
+                       return (sbyte)value;
+               }
+
+               public static sbyte ToSByte (sbyte value) 
+               { 
+                       return value;
+               }
+       
+               public static sbyte ToSByte (short value) 
+               { 
+                       if (value > SByte.MaxValue || value < SByte.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue or less than SByte.MinValue");
+         
+                       return (sbyte)value; 
+               }
+
+               public static sbyte ToSByte (string value) 
+               {
+                       return SByte.Parse (value);
+               }
+
+               public static sbyte ToSByte (string value, IFormatProvider provider) 
+               {
+                       return SByte.Parse (value, provider);
+               }
+       
+               public static sbyte ToSByte (uint value) 
+               { 
+                       if (value > SByte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue");
+
+                       return (sbyte)value;
+               }
+
+               public static sbyte ToSByte (ulong value) 
+               { 
+                       if (value > (ulong)SByte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue");
+
+                       return (sbyte)value;
+               }
+
+               public static sbyte ToSByte (ushort value) 
+               { 
+                       if (value > SByte.MaxValue)
+                               throw new OverflowException
+                               ("Value is greater than SByte.MaxValue");
+
+                       return (sbyte)value;
+               }
+
+               // ========== Single Conversions ========== //
+       
+               public static float ToSingle (bool value) 
+               { 
+                       return value ? 1 : 0; 
+               }
+       
+               public static float ToSingle (byte value) 
+               { 
+                       return (float)value; 
+               }
+       
+               public static float ToSingle (decimal value) 
+               { 
+                       return (float)value; 
+               }
+
+               public static float ToSingle (double value) 
+               { 
+                       if (value > Single.MaxValue || value < Single.MinValue)
+                               throw new OverflowException
+                               ("Value is greater than Single.MaxValue or less than Single.MinValue");
+
+                       return (float)value; 
+               }
+       
+               public static float ToSingle (float value) 
+               { 
+                       return value; 
+               }
+
+               public static float ToSingle (int value) 
+               { 
+                       return (float)value; 
+               }
+       
+               public static float ToSingle (long value) 
+               { 
+                       return (float)value; 
+               }
+
+               public static float ToSingle (sbyte value) 
+               { 
+                       return (float)value; 
+               }
+       
+               public static float ToSingle (short value) 
+               { 
+                       return (float)value; 
+               }
+
+               public static float ToSingle (string value) 
+               {
+                       return Single.Parse (value);
+               }
+
+               public static float ToSingle (string value, IFormatProvider provider) 
+               {
+                       return Single.Parse (value, provider);
+               }
+       
+               public static float ToSingle (uint value) 
+               { 
+                       return (float)value; 
+               }
+
+               public static float ToSingle (ulong value) 
+               { 
+                       return (float)value; 
+               }
+
+               public static float ToSingle (ushort value) 
+               { 
+                       return (float)value; 
+               }
+
+               // ========== String Conversions ========== //
+       
+               public static string ToString (bool value) 
+               { 
+                       return value.ToString (); 
+               }
+       
+               public static string ToString (byte value) 
+               { 
+                       return value.ToString (); 
+               }
+       
+               public static string ToString (byte value, IFormatProvider provider) 
+               {
+                       return value.ToString (provider); 
+               }
+
+               public static string ToString (char value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (DateTime value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (DateTime value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+
+               public static string ToString (decimal value) 
+               {
+                       return value.ToString ();
+               }
+
+               public static string ToString (decimal value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+       
+               public static string ToString (double value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (double value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider);
+               }
+       
+               public static string ToString (float value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (float value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+
+               public static string ToString (int value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (int value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+       
+               public static string ToString (long value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (long value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+
+               public static string ToString (sbyte value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (sbyte value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+       
+               public static string ToString (short value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (short value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+
+               public static string ToString (string value) 
+               {
+                       return value;
+               }
+
+               public static string ToString (uint value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (uint value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+
+               public static string ToString (ulong value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (ulong value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+
+               public static string ToString (ushort value) 
+               { 
+                       return value.ToString (); 
+               }
+
+               public static string ToString (ushort value, IFormatProvider provider) 
+               { 
+                       return value.ToString (provider); 
+               }
+
+               // ========== UInt16 Conversions ========== //
+
+               public static ushort ToUInt16 (bool value) 
+               { 
+                       return (ushort)(value ? 1 : 0); 
+               }
+       
+               public static ushort ToUInt16 (byte value) 
+               { 
+                       return (ushort)value; 
+               }
+
+               public static ushort ToUInt16 (char value) 
+               { 
+                       return (ushort)value; 
+               }
+       
+               public static ushort ToUInt16 (decimal value) 
+               { 
+                       if (value > UInt16.MaxValue || value < UInt16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (ushort)(Math.Round (value));      
+               }
+
+               public static ushort ToUInt16 (double value) 
+               { 
+                       if (value > UInt16.MaxValue || value < UInt16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (ushort)(Math.Round (value));
+               }
  
-       public static ushort ToUInt16(float value) { 
-           if(value > UInt16.MaxValue || value < UInt16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
-           
-           return (ushort)value;
-       }
-
-       public static ushort ToUInt16(int value) { 
-           if(value > UInt16.MaxValue || value < UInt16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
-
-           return (ushort)value; 
-       }
-       
-       public static ushort ToUInt16(long value) { 
-           if(value > UInt16.MaxValue || value < UInt16.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
-
-           return (ushort)value; 
-       }
-
-       public static ushort ToUInt16(sbyte value) { 
-           if(value < UInt16.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt16.MinValue");
-
-           return (ushort)value;  
-       }
-       
-       public static ushort ToUInt16(short value) { 
-           if(value < UInt16.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt16.MinValue");
-
-           return (ushort)value;  
-       }
-
-       public static ushort ToUInt16(string value) {
-           return UInt16.Parse(value);
-       }
-
-       public static ushort ToUInt16(string value, IFormatProvider provider) {
-           return UInt16.Parse(value, provider);
-       }
-       
-       public static ushort ToUInt16(uint value) { 
-           if(value > UInt16.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt16.MaxValue");
-
-           return (ushort)value; 
-       }
-
-       public static ushort ToUInt16(ulong value) { 
-           if(value > (ulong)UInt16.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt16.MaxValue");
-
-           return (ushort)value; 
-       }
-
-       public static ushort ToUInt16(ushort value) { 
-           return value; 
-       }
-
-       // ========== UInt32 Conversions ========== //
-
-       public static uint ToUInt32(bool value) { 
-           return (uint)(value ? 1 : 0); 
-       }
-       
-       public static uint ToUInt32(byte value) { 
-           return (uint)value; 
-       }
-
-       public static uint ToUInt32(char value) { 
-           return (uint)value; 
-       }
-       
-       public static uint ToUInt32(decimal value) { 
-           if(value > UInt32.MaxValue || value < UInt32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
-           
-           return (uint)value;     
-       }
-
-       public static uint ToUInt32(double value) { 
-           if(value > UInt32.MaxValue || value < UInt32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
-           
-           return (uint)value;     
-       }
+               public static ushort ToUInt16 (float value) 
+               { 
+                       if (value > UInt16.MaxValue || value < UInt16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
+         
+                       // Returned Even-Rounded, pass as double to Math
+                       return (ushort)(Math.Round ( (double)value));
+               }
+
+               public static ushort ToUInt16 (int value) 
+               { 
+                       if (value > UInt16.MaxValue || value < UInt16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
+
+                       return (ushort)value; 
+               }
+       
+               public static ushort ToUInt16 (long value) 
+               { 
+                       if (value > UInt16.MaxValue || value < UInt16.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt16.MaxValue or less than UInt16.MinValue");
+
+                       return (ushort)value; 
+               }
+
+               public static ushort ToUInt16 (sbyte value) 
+               { 
+                       if (value < UInt16.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt16.MinValue");
+
+                       return (ushort)value; 
+               }
+       
+               public static ushort ToUInt16 (short value) 
+               { 
+                       if (value < UInt16.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt16.MinValue");
+
+                       return (ushort)value; 
+               }
+
+               public static ushort ToUInt16 (string value) 
+               {
+                       return UInt16.Parse (value);
+               }
+
+               public static ushort ToUInt16 (string value, IFormatProvider provider) 
+               {
+                       return UInt16.Parse (value, provider);
+               }
+       
+               public static ushort ToUInt16 (uint value) 
+               { 
+                       if (value > UInt16.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt16.MaxValue");
+
+                       return (ushort)value; 
+               }
+
+               public static ushort ToUInt16 (ulong value) 
+               { 
+                       if (value > (ulong)UInt16.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt16.MaxValue");
+
+                       return (ushort)value; 
+               }
+
+               public static ushort ToUInt16 (ushort value) 
+               { 
+                       return value; 
+               }
+
+               // ========== UInt32 Conversions ========== //
+
+               public static uint ToUInt32 (bool value) 
+               { 
+                       return (uint)(value ? 1 : 0); 
+               }
+       
+               public static uint ToUInt32 (byte value) 
+               { 
+                       return (uint)value; 
+               }
+
+               public static uint ToUInt32 (char value) 
+               { 
+                       return (uint)value; 
+               }
+       
+               public static uint ToUInt32 (decimal value) 
+               { 
+                       if (value > UInt32.MaxValue || value < UInt32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (uint)(Math.Round (value));        
+               }
+
+               public static uint ToUInt32 (double value) 
+               { 
+                       if (value > UInt32.MaxValue || value < UInt32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (uint)(Math.Round (value));        
+               }
  
-       public static uint ToUInt32(float value) { 
-           if(value > UInt32.MaxValue || value < UInt32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
-           
-           return (uint)value;
-       }
-
-       public static uint ToUInt32(int value) { 
-           if(value < UInt32.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt32.MinValue");
-
-           return (uint)value; 
-       }
-       
-       public static uint ToUInt32(long value) { 
-           if(value > UInt32.MaxValue || value < UInt32.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
-
-           return (uint)value; 
-       }
-
-       public static uint ToUInt32(sbyte value) { 
-           if(value < UInt32.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt32.MinValue");
-
-           return (uint)value;  
-       }
-       
-       public static uint ToUInt32(short value) { 
-           if(value < UInt32.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt32.MinValue");
-
-           return (uint)value; 
-       }
-
-       public static uint ToUInt32(string value) {
-           return UInt32.Parse(value);
-       }
-
-       public static uint ToUInt32(string value, IFormatProvider provider) {
-           return UInt32.Parse(value, provider);
-       }
-       
-       public static uint ToUInt32(uint value) { 
-           return value; 
-       }
-
-       public static uint ToUInt32(ulong value) { 
-           if(value > UInt32.MaxValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt32.MaxValue");
-
-           return (uint)value; 
-       }
-
-       public static uint ToUInt32(ushort value) { 
-           return (uint)value; 
-       }
-
-       // ========== UInt64 Conversions ========== //
-
-       public static ulong ToUInt64(bool value) { 
-           return (ulong)(value ? 1 : 0); 
-       }
-       
-       public static ulong ToUInt64(byte value) { 
-           return (ulong)value; 
-       }
-
-       public static ulong ToUInt64(char value) { 
-           return (ulong)value; 
-       }
-       
-       public static ulong ToUInt64(decimal value) { 
-           if(value > UInt64.MaxValue || value < UInt64.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt64.MaxValue or less than UInt64.MinValue");
-           
-           return (ulong)value;            
-       }
-
-       public static ulong ToUInt64(double value) { 
-           if(value > UInt64.MaxValue || value < UInt64.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt64.MaxValue or less than UInt64.MinValue");
-           
-           return (ulong)value;            
-       }
+               public static uint ToUInt32 (float value) 
+               { 
+                       if (value > UInt32.MaxValue || value < UInt32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
+         
+                       // Returned Even-Rounded, pass as double to Math
+                       return (uint)(Math.Round ( (double)value));
+               }
+
+               public static uint ToUInt32 (int value) 
+               { 
+                       if (value < UInt32.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt32.MinValue");
+
+                       return (uint)value; 
+               }
+       
+               public static uint ToUInt32 (long value) 
+               { 
+                       if (value > UInt32.MaxValue || value < UInt32.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt32.MaxValue or less than UInt32.MinValue");
+
+                       return (uint)value; 
+               }
+
+               public static uint ToUInt32 (sbyte value) 
+               { 
+                       if (value < UInt32.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt32.MinValue");
+
+                       return (uint)value; 
+               }
+       
+               public static uint ToUInt32 (short value) 
+               { 
+                       if (value < UInt32.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt32.MinValue");
+
+                       return (uint)value; 
+               }
+
+               public static uint ToUInt32 (string value) 
+               {
+                       return UInt32.Parse (value);
+               }
+
+               public static uint ToUInt32 (string value, IFormatProvider provider) 
+               {
+                       return UInt32.Parse (value, provider);
+               }
+       
+               public static uint ToUInt32 (uint value) 
+               { 
+                       return value; 
+               }
+
+               public static uint ToUInt32 (ulong value) 
+               { 
+                       if (value > UInt32.MaxValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt32.MaxValue");
+
+                       return (uint)value; 
+               }
+
+               public static uint ToUInt32 (ushort value) 
+               { 
+                       return (uint)value; 
+               }
+
+               // ========== UInt64 Conversions ========== //
+
+               public static ulong ToUInt64 (bool value) 
+               { 
+                       return (ulong)(value ? 1 : 0); 
+               }
+       
+               public static ulong ToUInt64 (byte value) 
+               { 
+                       return (ulong)value; 
+               }
+
+               public static ulong ToUInt64 (char value) 
+               { 
+                       return (ulong)value; 
+               }
+       
+               public static ulong ToUInt64 (decimal value) 
+               { 
+                       if (value > UInt64.MaxValue || value < UInt64.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt64.MaxValue or less than UInt64.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (ulong)(Math.Round (value));       
+               }
+
+               public static ulong ToUInt64 (double value) 
+               { 
+                       if (value > UInt64.MaxValue || value < UInt64.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt64.MaxValue or less than UInt64.MinValue");
+         
+                       // Returned Even-Rounded
+                       return (ulong)(Math.Round (value));       
+               }
  
-       public static ulong ToUInt64(float value) { 
-           if(value > UInt64.MaxValue || value < UInt64.MinValue) 
-               throw new OverflowException
-                   ("Value is greater than UInt64.MaxValue or less than UInt64.MinValue");
-           
-           return (ulong)value;
-       }
-
-       public static ulong ToUInt64(int value) { 
-           if(value < (int)UInt64.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt64.MinValue");
-
-           return (ulong)value; 
-       }
-       
-       public static ulong ToUInt64(long value) { 
-           if(value < (long)UInt64.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt64.MinValue");
-
-           return (ulong)value; 
-       }
-
-       public static ulong ToUInt64(sbyte value) { 
-           if(value < (sbyte)UInt64.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt64.MinValue");
-
-           return (ulong)value;  
-       }
-       
-       public static ulong ToUInt64(short value) { 
-           if(value < (short)UInt64.MinValue) 
-               throw new OverflowException
-                   ("Value is less than UInt64.MinValue");
-
-           return (ulong)value; 
-       }
-
-       public static ulong ToUInt64(string value) {
-           return UInt64.Parse(value);
-       }
-
-       public static ulong ToUInt64(string value, IFormatProvider provider) {
-           return UInt64.Parse(value, provider);
-       }
-       
-       public static ulong ToUInt64(uint value) { 
-           return (ulong)value; 
-       }
-
-       public static ulong ToUInt64(ulong value) { 
-           return value; 
-       }
-
-       public static ulong ToUInt64(ushort value) { 
-           return (ulong)value; 
+               public static ulong ToUInt64 (float value) 
+               { 
+                       if (value > UInt64.MaxValue || value < UInt64.MinValue) 
+                               throw new OverflowException
+                               ("Value is greater than UInt64.MaxValue or less than UInt64.MinValue");
+         
+                       // Returned Even-Rounded, pass as a double to Math
+                       return (ulong)(Math.Round ( (double)value));
+               }
+
+               public static ulong ToUInt64 (int value) 
+               { 
+                       if (value < (int)UInt64.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt64.MinValue");
+
+                       return (ulong)value; 
+               }
+       
+               public static ulong ToUInt64 (long value) 
+               { 
+                       if (value < (long)UInt64.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt64.MinValue");
+
+                       return (ulong)value; 
+               }
+
+               public static ulong ToUInt64 (sbyte value) 
+               { 
+                       if (value < (sbyte)UInt64.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt64.MinValue");
+
+                       return (ulong)value; 
+               }
+       
+               public static ulong ToUInt64 (short value) 
+               { 
+                       if (value < (short)UInt64.MinValue) 
+                               throw new OverflowException
+                               ("Value is less than UInt64.MinValue");
+
+                       return (ulong)value; 
+               }
+
+               public static ulong ToUInt64 (string value) 
+               {
+                       return UInt64.Parse (value);
+               }
+
+               public static ulong ToUInt64 (string value, IFormatProvider provider) 
+               {
+                       return UInt64.Parse (value, provider);
+               }
+       
+               public static ulong ToUInt64 (uint value) 
+               { 
+                       return (ulong)value; 
+               }
+
+               public static ulong ToUInt64 (ulong value) 
+               { 
+                       return value; 
+               }
+
+               public static ulong ToUInt64 (ushort value) 
+               { 
+                       return (ulong)value; 
+               }
+
+               // ========== Conversion / Helper Fucntions ========== //
+       
+               // Lookup table for the conversion ToType method. Order
+               // is important! Used by ToType for comparing the target
+               // type, and uses hardcoded array indexes.
+               private static Type[] conversionTable = {
+                       // Valid ICovnertible Types
+                       typeof (Boolean),  //  0 TypeCode.Boolean
+                       typeof (Byte),     //  1 TypeCode.Byte
+                       typeof (Char),     //  2 TypeCode.Char
+                       typeof (DateTime), //  3 TypeCode.DateTime
+                       typeof (Decimal),  //  4 TypeCode.Decimal
+                       typeof (Double),   //  5 TypeCode.Double
+                       typeof (Int16),    //  6 TypeCode.Int16
+                       typeof (Int32),    //  7 TypeCode.Int32
+                       typeof (Int64),    //  8 TypeCode.Int64
+                       typeof (SByte),    //  9 TypeCode.Sbyte
+                       typeof (Single),   // 10 TypeCode.Single
+                       typeof (String),   // 11 TypeCode.String
+                       typeof (UInt16),   // 12 TypeCode.UInt16
+                       typeof (UInt32),   // 13 TypeCode.UInt32
+                       typeof (UInt64),   // 14 TypeCode.UInt64
+         
+                       // Invalid IConvertible Interface Types
+                       typeof (Object)    // 15 TypeCode.Object
+               };
+
+               // Function to convert an object to another type and return
+               // it as an object. In place for the core data types to use
+               // when implementing IConvertible. Uses hardcoded indexes in 
+               // the conversionTypes array, so if modify carefully.
+               internal static object ToType (object value, Type conversionType, 
+                                              IFormatProvider provider) 
+               {
+                       if (value == null)
+                               throw new ArgumentException
+                               ("Invalid conversion from null value");
+
+                       if (value is IConvertible) {
+                               IConvertible convertValue = (IConvertible)value;
+
+                               if (conversionType == conversionTable[0]) {
+                                       // 0 TypeCode.Boolean
+                                       return (object)(convertValue.ToBoolean (provider));
+
+                               } else if (conversionType == conversionTable[1]) {
+                                       // 1 TypeCode.Byte
+                                       return (object)(convertValue.ToByte (provider));
+                 
+                               } else if (conversionType == conversionTable[2]) {
+                                       // 2 TypeCode.Char
+                                       return (object)(convertValue.ToChar (provider));
+                 
+                               } else if (conversionType == conversionTable[3]) {
+                                       // 3 TypeCode.DateTime
+                                       return (object)(convertValue.ToDateTime (provider));
+                 
+                               } else if (conversionType == conversionTable[4]) {
+                                       // 4 TypeCode.Decimal
+                                       return (object)(convertValue.ToDecimal (provider));
+                 
+                               } else if (conversionType == conversionTable[5]) {
+                                       // 5 TypeCode.Double
+                                       return (object)(convertValue.ToDouble (provider));
+
+                               } else if (conversionType == conversionTable[6]) {
+                                       // 6 TypeCode.Int16
+                                       return (object)(convertValue.ToInt16 (provider));
+                 
+                               } else if (conversionType == conversionTable[7]) {
+                                       // 7 TypeCode.Int32
+                                       return (object)(convertValue.ToInt32 (provider));
+                 
+                               } else if (conversionType == conversionTable[8]) {
+                                       // 8 TypeCode.Int64
+                                       return (object)(convertValue.ToInt64 (provider));
+                 
+                               } else if (conversionType == conversionTable[9]) {
+                                       // 9 TypeCode.Sbyte
+                                       return (object)(convertValue.ToSByte (provider));
+                 
+                               } else if (conversionType == conversionTable[10]) {
+                                       // 10 TypeCode.Single
+                                       return (object)(convertValue.ToSingle (provider));
+                 
+                               } else if (conversionType == conversionTable[11]) {
+                                       // 11 TypeCode.String
+                                       return (object)(convertValue.ToString (provider));
+                 
+                               } else if (conversionType == conversionTable[12]) {  
+                                       // 12 TypeCode.UInt16
+                                       return (object)(convertValue.ToUInt16 (provider));
+                 
+                               } else if (conversionType == conversionTable[13]) {
+                                       // 13 TypeCode.UInt32
+                                       return (object)(convertValue.ToUInt32 (provider));
+                 
+                               } else if (conversionType == conversionTable[14]) {
+                                       // 14 TypeCode.UInt64
+                                       return (object)(convertValue.ToUInt64 (provider));
+
+                               } else if (conversionType == conversionTable[15]) {
+                                       // 15 TypeCode.Object
+                                       return (object)(value);
+
+                               } else  {               
+                                       // Not in the conversion table
+                                       throw new InvalidCastException
+                                       ("Unknown target conversion type");
+                               }
+                       } else {
+                               // Value is not IConvertible
+                               throw new ArgumentException
+                               ("Value is not a convertible object");
+                       }
+               }
        }
-    } 
 }
index f00a70e034fc20460adabebb716d1dc5f4c5aed7..371a00af1669d1dc5d5a52a19454eb1e92972088 100644 (file)
 //
 // System.DateTime.cs
 //
-// This implementation is just to get String.cs to compile
+// author:
+//   Marcel Narings (marcel@narings.nl)
 //
+//   (C) 2001 Marcel Narings
 
-using System.Globalization;
-namespace System {
+using System.Globalization ;
+namespace System
+{
 
-       public struct DateTime : IComparable {
-               
+       public struct DateTime : IComparable //, IFormattable, IConvertible
+       {
                long ticks;
 
-               public DateTime (long ticks)
+               public static readonly DateTime MaxValue = new DateTime(3155378975999999999L);
+               public static readonly DateTime MinValue = new DateTime(0L);
+               
+               private enum Which 
+               {
+                       Day,
+                       DayYear,
+                       Month,
+                       Year
+               };
+
+               // Constructors
+               public DateTime (long newticks) 
+               {
+                       ticks = newticks;
+               
+                       if ( newticks < MinValue.ticks || newticks > MaxValue.ticks)
+                               throw new ArgumentOutOfRangeException ();
+               }
+
+               public DateTime (int year, int month, int day)
+                       : this (year, month, day,0,0,0,0) {}
+
+               public DateTime (int year, int month, int day, int hour, int minute, int second)
+                       : this (year, month, day, hour, minute, second, 0)      {}
+
+               public DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond)
+               {
+                       if ( year < 1 || year > 9999 || 
+                               month < 1 || month >12  ||
+                               day < 1 || day > DaysInMonth(year, month) ||
+                               hour < 0 || hour > 23 ||
+                               minute < 0 || minute > 59 ||
+                               second < 0 || second > 59 )
+                               throw new ArgumentOutOfRangeException() ;
+                               
+                       ticks = AbsoluteDays(year,month,day) * TimeSpan.TicksPerDay + 
+                               hour * TimeSpan.TicksPerHour + 
+                               minute * TimeSpan.TicksPerMinute + 
+                               second * TimeSpan.TicksPerSecond + 
+                               millisecond * TimeSpan.TicksPerMillisecond ; 
+                       
+                       if (ticks < MinValue.ticks || ticks > MaxValue.ticks )
+                               throw new ArgumentException() ;
+               }
+
+               public DateTime (int year, int month, int day, Calendar calendar)
+                       : this (year, month, day, 0, 0, 0, 0, calendar) {}
+
+               
+               public DateTime (int year, int month, int day, int hour, int minute, int second, Calendar calendar)
+                       : this (year, month, day, hour, minute, second, 0, calendar)    {}
+
+
+               public DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, Calendar calendar)
+                       : this(year, month, day, hour, minute, second, millisecond) 
+               {
+                       // TODO implement calendar
+               }
+
+
+               /* Properties  */
+                
+               public DateTime Date 
+               {
+                       get     
+                       { 
+                               return new DateTime(ticks - (ticks % TimeSpan.TicksPerDay )) ; 
+                       }
+               }
+        
+               public int Day
+               {
+                       get 
+                       { 
+                               return FromTicks(Which.Day); 
+                       }
+               }
+
+               public DayOfWeek DayOfWeek 
+               {
+                       get 
+                       { 
+                               return (DayOfWeek) (((ticks / TimeSpan.TicksPerDay)+1) % 7); 
+                       }
+               }
+
+               public int DayOfYear 
+               {
+                       get 
+                       { 
+                               return FromTicks(Which.DayYear); 
+                       }
+               }
+
+               public int Hour 
+               {
+                       get 
+                       { 
+                               return (int) ((ticks % TimeSpan.TicksPerDay) / TimeSpan.TicksPerHour);  
+                       }
+               }
+
+               public int Millisecond 
+               {
+                       get 
+                       { 
+                               return (int) (ticks % TimeSpan.TicksPerSecond / TimeSpan.TicksPerMillisecond); 
+                       }
+               }
+               
+               public int Minute 
+               {
+                       get 
+                       { 
+                               return (int) (ticks % TimeSpan.TicksPerHour / TimeSpan.TicksPerMinute); 
+                       }
+               }
+
+               public int Month 
+               {
+                       get 
+                       { 
+                               return FromTicks(Which.Month); 
+                       }
+               }
+
+               // TODO IMPLEMENT ME 
+               //public static DateTime Now {get;}
+
+               public int Second 
+               {
+                       get 
+                       { 
+                               return (int) (ticks % TimeSpan.TicksPerMinute / TimeSpan.TicksPerSecond); 
+                       }
+               }
+
+               public long Ticks
+               { 
+                       get 
+                       { 
+                               return ticks ; 
+                       }
+               }
+       
+               public TimeSpan TimeOfDay 
+               {
+                       get 
+                       { 
+                               return new TimeSpan(ticks % TimeSpan.TicksPerDay );
+                       }
+                       
+               }
+
+               //TODO implement
+               //public static DateTime Today {get;}
+
+               //TODO implement
+               //public static DateTime UtcNow {get;}
+
+               public int Year 
                {
-                       this.ticks = ticks;
+                       get 
+                       { 
+                               return FromTicks(Which.Year); 
+                       }
                }
 
+
+               /* methods */
+
+               public DateTime AddTicks( long t )
+               {
+                       return new DateTime(ticks + t);
+               }
+
+               // FIXME: Implement me.
+               public DateTime AddDays( double days )
+               {
+                       return new DateTime (0);
+               }
+
+               // TODO: Implement me.
+               public DateTime AddHours( double hours )
+               {
+                       return new DateTime (0);
+               }
+
+               // TODO: Implement me.
+               public DateTime AddMilliseconds( double ms      )
+               {
+                       return new DateTime (0);
+               }
+
+               // TODO: Implement me.
+               public DateTime AddMinutes(     double minutes )
+               {
+                       return new DateTime (0);
+               }
+               
+               // TODO: Implement me.
+               public DateTime AddMonths( int months )
+               {
+                       return new DateTime (0);
+               }
+
+               // TODO: Implement me.
+               public DateTime AddSeconds(double seconds )
+               {
+                       return new DateTime (0);
+               }
+
+               // TODO: Implement me.
+               public DateTime AddYears(int years )
+               {
+                       return new DateTime (0);
+               }
+
+               public static int Compare( DateTime t1, DateTime t2     )
+               {
+                       if (t1.ticks < t2.ticks) 
+                               return -1;
+                       else if (t1.ticks > t2.ticks) 
+                               return 1;
+                       else
+                               return 0;
+               }
+
+               // FIXME check this
                public int CompareTo (object v)
                {
+                       if ( v == null)
+                               return 1 ;
+
                        if (!(v is System.DateTime))
                                throw new ArgumentException ("Value is not a System.DateTime");
 
-                       return (int) (ticks - ((DateTime) v).ticks);
+                       return Compare (this , (DateTime) v);
+               }
+
+               public static int DaysInMonth(int year, int month)
+               {
+                       int[] dayspermonth = new int[13] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
+
+                       if (month < 1 || month >12)
+                               throw new ArgumentOutOfRangeException ();
+                
+                       if (month == 2 && IsLeapYear(year))
+                               return 29;
+                       else
+                               return dayspermonth[month];                     
                }
 
+               
                public override bool Equals (object o)
                {
                        if (!(o is System.DateTime))
@@ -32,6 +277,36 @@ namespace System {
                        return ((DateTime) o).ticks == ticks;
                }
 
+               public static new bool Equals(DateTime t1, DateTime t2 )
+               {
+                       return (t1.ticks == t2.ticks );
+               }
+
+               // TODO: Implement me.
+               public static DateTime FromFileTime(long fileTime) 
+               {
+                       return new DateTime(0);
+               }
+
+               // TODO: Implement me.
+               public static DateTime FromOADate(double d)
+               {
+                       return new DateTime(0);
+               }
+               
+               // TODO: Implement me.
+               //public string[] GetDateTimeFormats();
+
+               //TODO: implement me 
+               //public string[] GetDateTimeFormats(   char format     )
+               
+               // TODO: implement me 
+               //public string[] GetDateTimeFormats(   IFormatProvider provider)
+
+               //TODO: implement me 
+               //public string[] GetDateTimeFormats(char format,IFormatProvider provider       )
+
+
                public override int GetHashCode ()
                {
                        return (int) ticks;
@@ -42,6 +317,11 @@ namespace System {
                        return TypeCode.DateTime;
                }
 
+               public static bool IsLeapYear(int year)
+               {
+                       return ( !(year %4 > 0 ) && (year %100 > 0) || !(year %400 > 0) ) ;
+               }
+
                public static DateTime Parse (string s)
                {
                        // TODO: Implement me
@@ -60,6 +340,79 @@ namespace System {
                        return new DateTime (0);
                }
 
+               public static DateTime ParseExact(string s,     string format, IFormatProvider provider )
+               {
+                       // TODO: Implement me
+                       return new DateTime (0);
+               }
+
+               public static DateTime ParseExact(      string s, string format, IFormatProvider provider,      DateTimeStyles style )
+               {
+                       // TODO: Implement me
+                       return new DateTime (0);
+               
+               }
+
+               public static DateTime ParseExact( string s, string[] formats, IFormatProvider provider, DateTimeStyles style )
+               {
+                       // TODO: Implement me
+                       return new DateTime (0);
+               
+               }
+               
+               public TimeSpan Subtract(DateTime dt )
+               {   //TODO : implement me
+                       return new TimeSpan(ticks - dt.ticks );
+               }
+
+               public DateTime Subtract(TimeSpan ts)
+               {       // TODO : implement me 
+                       return new DateTime(ticks - ts.Ticks );
+               }
+
+               public long ToFileTime()
+               {
+                               // TODO: Implement me
+                       return 0 ;
+               }
+
+               public DateTime ToLocalTime()
+               {
+                       // TODO Implement me 
+                       return new DateTime (0);
+               }
+
+               public string ToLongDateString()
+               {
+                       // TODO implement me 
+                       return "";
+               }
+
+               public string ToLongTimeString()
+               {
+                       // TODO implement me 
+                       return "";
+               }
+
+               public double ToOADate()
+               {
+                       // TODO implement me 
+                       return 0;
+               }
+
+               public string ToShortDateString()
+               {
+                       // TODO implement me 
+                       return "";
+               }
+
+               public string ToShortTimeString()
+               {
+                       // TODO implement me
+                       return "";
+               }
+        
+
                public override string ToString ()
                {
                        // TODO: Implement me
@@ -84,5 +437,134 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               public DateTime ToUniversalTime()
+               {
+                       // TODO: implement me 
+                       return new DateTime(0);
+               }
+
+               /*  OPERATORS */
+
+               public static DateTime operator +( DateTime d,  TimeSpan t )
+               {
+                       return new DateTime (d.ticks + t.Ticks );
+               }
+
+               public static bool operator ==( DateTime d1, DateTime d2 )
+               {
+                       return (d1.ticks == d2.ticks );
+               }
+
+               public static bool operator >(DateTime t1,DateTime t2)
+               {
+                       return (t1.ticks > t2.ticks );
+               }
+
+               public static bool operator >=( DateTime t1,DateTime t2 )
+               {
+                       return (t1.ticks >= t2.ticks);
+               }
+
+               public static bool operator !=( DateTime d1, DateTime d2)
+               {
+                       return (d1.ticks != d2.ticks );
+               }
+
+               public static bool operator <( DateTime t1,     DateTime t2     )
+               {
+                       return (t1.ticks < t2.ticks );
+               }
+
+               public static bool operator <=( DateTime t1,DateTime t2 )
+               {
+                       return (t1.ticks <= t2.ticks );
+               }
+
+               public static TimeSpan operator -(DateTime d1,DateTime d2)
+               {
+                       return new TimeSpan(d1.ticks - d2.ticks );
+               }
+
+               public static DateTime operator -(DateTime d,TimeSpan t )
+               {
+                       return new DateTime (d.ticks - t.Ticks );
+               }
+
+
+
+               private static long AbsoluteDays (int year, int month, int day)
+               {
+                       int[] days = new int[13] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
+                       int temp = 0, m=1 ;
+               
+                       if (IsLeapYear(year))
+                               days[2] = 29;
+                       while (m < month)
+                               temp += days[m++];
+                       return ((day-1) + temp + (365* (year-1)) + ((year-1)/4) - ((year-1)/100) + ((year-1)/400));
+                       
+               }
+
+               private  int FromTicks(Which what)
+               {
+                       const int dp400 = 146097;
+                       const int dp100 = 36524;
+                       const int dp4 = 1461;
+               
+                       int[] days = new int[13] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
+                       int totaldays = (int) (ticks / TimeSpan.TicksPerDay );
+               
+                       int num400 = (totaldays / dp400);
+                       totaldays -=  num400 * dp400;
+               
+                       int num100 = (totaldays / dp100);
+                       if (num100 == 4)   // leap
+                               num100 = 3;
+                       totaldays -= (num100 * dp100);
+
+                       int num4 = totaldays / dp4;
+                       totaldays -= (num4 * dp4);
+
+                       int numyears = totaldays / 365 ;
+                       
+                       if (numyears == 4)  //leap
+                               numyears =3 ;
+                       if (what == Which.Year )
+                               return num400*400 + num100*100 + num4*4 + numyears + 1;
+
+                       totaldays -= (numyears * 365) ;
+                       if (what ==Which.DayYear )
+                               return totaldays + 1;
+                       
+                       if  ((numyears==3) && ((num100 == 3) || !(num4 == 24)) ) //31 dec leapyear
+                               days[2] = 29;
+               
+               
+                       int M =1;
+                       while (totaldays >= days[M])
+                               totaldays -= days[M++];
+
+                       if (what == Which.Month )
+                               return M;
+
+                       return totaldays +1;
+               }
+
+       }
+}
+namespace System
+{
+       public enum DayOfWeek
+       {
+               Sunday,
+               Monday,
+               Tuesday,
+               Wednesday,
+               Thursday,
+               Friday,
+               Saturday
        }
 }
+
+               
index ba69f4d7b7499cab8e635c1cc45aca52ef56e923..af193760b4b8881262ae098c3148614d5dd1bb29 100644 (file)
@@ -11,15 +11,13 @@ using System.Globalization;
 
 namespace System {
        
-       public struct Double : IComparable, IFormattable {
-               /*
-                * FIXME: The MinValue and MaxValue are wrong!
-                */
-               public const double MinValue = -1.79769313486232e307;
-               public const double MaxValue =  1.79769313486232e307;
-               public const double NaN = (double) 0xfff8000000000000;
-               public const double NegativeInfinity = (double) 0xfff0000000000000;
-               public const double PositiveInfinity = (double) 0x7ff0000000000000;
+       public struct Double : IComparable, IFormattable { //, IConvertible {
+               public const double Epsilon = 4.9406564584124650e-324;
+               public const double MaxValue =  1.7976931348623157e308;
+               public const double MinValue = -1.7976931348623157e308;
+               public const double NaN = 0.0d / 0.0d;
+               public const double NegativeInfinity = -1.0d / 0.0d;
+               public const double PositiveInfinity = 1.0d / 0.0d;
                
                // VES needs to know about value.  public is workaround
                // so source will compile
@@ -46,24 +44,42 @@ namespace System {
                        return (int) value;
                }
 
-               public TypeCode GetTypeCode ()
+               public static bool IsInfinity (double d)
                {
-                       return TypeCode.Double;
+                       return (d == PositiveInfinity || d == NegativeInfinity);
                }
 
-               public static float Parse (string s)
+               public static bool IsNaN (double d)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return (d != d);
                }
 
-               public static float Parse (string s, IFormatProvider fp)
+               public static bool IsNegativeInfinity (double d)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return (d < 0.0d && (d == NegativeInfinity || d == PositiveInfinity));
+               }
+
+               public static bool IsPositiveInfinity (double d)
+               {
+                       return (d > 0.0d && (d == NegativeInfinity || d == PositiveInfinity));
+               }
+
+               public static double Parse (string s)
+               {
+                       return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), null);
                }
 
-               public static float Parse (string s, NumberStyles style, IFormatProvider fp)
+               public static double Parse (string s, IFormatProvider fp)
+               {
+                       return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), fp);
+               }
+
+               public static double Parse (string s, NumberStyles style) 
+               {
+                       return Parse (s, style, null);
+               }
+
+               public static double Parse (string s, NumberStyles style, IFormatProvider fp)
                {
                        // TODO: Implement me
                        return 0;
@@ -71,21 +87,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString (null, null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (null, fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -93,5 +105,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.Double;
+               }
        }
 }
index bfff8808b28f5b57bc56ae4a3657582274b9e963..62fd3d5b942984efcc931ec23f1c3f0bdb0aab27 100644 (file)
@@ -7,27 +7,48 @@
 // (C) Ximian, Inc.  http://www.ximian.com
 //
 
-namespace System {
-
-       public interface IConvertible {
+//
+// Functions Implementing this interface should check out 
+// System.Convert. Most of these methods are implemented 
+// there for all these data types.
+//
+// System.Convert has ToType helper method for the object 
+// ToType (Type conversionType, IFormatProvider provider)
+// method. In most cases you can specify your ToType function
+// as calling 
+//
+// public Type value; // value of this data type
+// public object ToType(Type conversionType, IFormatProvider provider) {
+//    Convert.ToType (value, conversionType, provider);
+// } 
+// 
+// Which is just a wrapper for your ToType methods.
+//
+// See http://lists.ximian.com/archives/public/mono-list/2001-July/000525.html
+// for more discussion on the topic
+//
 
-               TypeCode GetTypeCode ();
+namespace System {
 
-               bool     ToBoolean  (IFormatProvider provider);
-               byte     ToByte     (IFormatProvider provider);
-               char     ToChar     (IFormatProvider provider);
-               DateTime ToDateTime (IFormatProvider provider);
-               Decimal  ToDecimal  (IFormatProvider provider);
-               Double   ToDouble   (IFormatProvider provider);
-               Int16    ToInt16    (IFormatProvider provider);
-               Int32    ToInt32    (IFormatProvider provider);
-               Int64    ToInt64    (IFormatProvider provider);
-               SByte    ToSByte    (IFormatProvider provider);
-               float    ToSingle   (IFormatProvider provider);
-               string   ToString   (IFormatProvider provider);
-               object   ToType     (Type conversionType, IFormatProvider provider);
-               UInt16   ToUInt16   (IFormatProvider provider);
-               UInt32   ToUInt32   (IFormatProvider provider);
-               UInt64   ToUInt64   (IFormatProvider provider);
-       }
+    public interface IConvertible {
+       
+       TypeCode GetTypeCode ();
+       
+       bool     ToBoolean  (IFormatProvider provider);
+       byte     ToByte     (IFormatProvider provider);
+       char     ToChar     (IFormatProvider provider);
+       DateTime ToDateTime (IFormatProvider provider);
+       decimal  ToDecimal  (IFormatProvider provider);
+       double   ToDouble   (IFormatProvider provider);
+       short    ToInt16    (IFormatProvider provider);
+       int      ToInt32    (IFormatProvider provider);
+       long     ToInt64    (IFormatProvider provider);
+       sbyte    ToSByte    (IFormatProvider provider);
+       float    ToSingle   (IFormatProvider provider);
+       string   ToString   (IFormatProvider provider);
+       object   ToType     (Type conversionType, IFormatProvider provider);
+       ushort   ToUInt16   (IFormatProvider provider);
+       uint     ToUInt32   (IFormatProvider provider);
+       ulong    ToUInt64   (IFormatProvider provider);
+    }
 }
index ae05006d17a4039f5e53f6f2f5fc1457061e6672..c647fa40660b9ab5c493e8f28605917493e45425 100644 (file)
@@ -11,9 +11,9 @@ using System.Globalization;
 
 namespace System {
        
-       public struct Int16 : IComparable, IFormattable {
-               public const short MinValue = -32768;
+       public struct Int16 : IComparable, IFormattable { //, IConvertible {
                public const short MaxValue =  32767;
+               public const short MinValue = -32768;
                
                // VES needs to know about value.  public is workaround
                // so source will compile
@@ -40,21 +40,19 @@ namespace System {
                        return value;
                }
 
-               public TypeCode GetTypeCode ()
+               public static short Parse (string s)
                {
-                       return TypeCode.Int16;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
-               public static short Parse (string s)
+               public static short Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
-               public static short Parse (string s, IFormatProvider fp)
+               public static short Parse (string s, NumberStyles style)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, style, null);
                }
 
                public static short Parse (string s, NumberStyles style, IFormatProvider fp)
@@ -65,21 +63,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -87,5 +81,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.Int16;
+               }
        }
 }
index 57496ffa9b60ce3e2837f404084615f46e79ce0d..87c714db0aa9ad6e983fd77f1ad8d5ddd2be356c 100644 (file)
@@ -11,9 +11,9 @@ using System.Globalization;
 
 namespace System {
        
-       public struct Int32 : IComparable, IFormattable {
-               public const int MinValue = -2147483648;
+       public struct Int32 : IComparable, IFormattable { //, IConvertible {
                public const int MaxValue = 0x7fffffff;
+               public const int MinValue = -2147483648;
                
                public int value;
 
@@ -38,23 +38,21 @@ namespace System {
                        return value;
                }
 
-               public TypeCode GetTypeCode ()
-               {
-                       return TypeCode.Int32;
-               }
-
                public static int Parse (string s)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
                public static int Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
+               public static int Parse (string s, NumberStyles style)
+               {
+                       return Parse (s, style, null);
+               }
+               
                public static int Parse (string s, NumberStyles style, IFormatProvider fp)
                {
                        // TODO: Implement me
@@ -63,21 +61,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -85,5 +79,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.Int32;
+               }
        }
 }
index 4744b6d08176ff3b0899b63a9828d71c9bf15bb5..3af2fe6cdd8fdaf8cfa9f98de7d4f17a4f483b28 100644 (file)
@@ -11,9 +11,9 @@ using System.Globalization;
 
 namespace System {
        
-       public struct Int64 : IComparable, IFormattable {
-               public const long MinValue = -9223372036854775808;
+       public struct Int64 : IComparable, IFormattable { //, IConvertible {
                public const long MaxValue = 0x7fffffffffffffff;
+               public const long MinValue = -9223372036854775808;
                
                public long value;
 
@@ -44,21 +44,19 @@ namespace System {
                        return (int)(value & 0xffffffff) ^ (int)(value >> 32);
                }
 
-               public TypeCode GetTypeCode ()
+               public static long Parse (string s)
                {
-                       return TypeCode.Int64;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
-               public static long Parse (string s)
+               public static long Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
-               public static long Parse (string s, IFormatProvider fp)
+               public static long Parse (string s, NumberStyles style)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, style, null);
                }
 
                public static long Parse (string s, NumberStyles style, IFormatProvider fp)
@@ -69,21 +67,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -91,5 +85,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.Int64;
+               }
        }
 }
index 3eec3db98592dd579947e919e7de1d104d5d7a59..258dff58012599307a351c62e07143d55130c9ab 100644 (file)
@@ -11,7 +11,7 @@ using System.Globalization;
 
 namespace System {
        
-       public struct SByte : IComparable, IFormattable {
+       public struct SByte : IComparable, IFormattable { //, IConvertible {
                public const sbyte MinValue = -128;
                public const sbyte MaxValue = 127;
                
@@ -40,21 +40,19 @@ namespace System {
                        return value;
                }
 
-               public TypeCode GetTypeCode ()
+               public static sbyte Parse (string s)
                {
-                       return TypeCode.Byte;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
-               public static sbyte Parse (string s)
+               public static sbyte Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
-               public static sbyte Parse (string s, IFormatProvider fp)
+               public static sbyte Parse (string s, NumberStyles style)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, style, null);
                }
 
                public static sbyte Parse (string s, NumberStyles style, IFormatProvider fp)
@@ -65,21 +63,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -87,5 +81,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== ICovnertible Methods =========== //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.Byte;
+               }
        }
 }
index e6bb07e1d942f10eeea80bd3d080fdb0890b0669..cb898bdeb98355c52c9ee1251ab348cabbdbdd72 100644 (file)
@@ -11,19 +11,18 @@ using System.Globalization;
 
 namespace System {
        
-       public struct Single : IComparable, IFormattable {
-               public const float MinValue = (float) -3.402823e38;
-               public const float MaxValue = (float) 3.402823e38;
-               public const float NaN = (float) 0xffc00000;
-               public const float NegativeInfinity = (float) 0xff800000;
-               public const float PositiveInfinity = (float) 0x7f800000;
+       public struct Single : IComparable, IFormattable { //, IConvertible {
+               public const float Epsilon = 1.4e-45f;
+               public const float MaxValue =  3.40282346638528859e38f;
+               public const float MinValue = -3.40282346638528859e38f;
+               public const float NaN = 0.0f / 0.0f;
+               public const float PositiveInfinity =  1.0f / 0.0f;
+               public const float NegativeInfinity = -1.0f / 0.0f;
                        
                // VES needs to know about value.  public is workaround
                // so source will compile
                public float value;
-
-               
-               
+                       
                public int CompareTo (object v)
                {
                        if (!(v is System.Single))
@@ -45,21 +44,39 @@ namespace System {
                        return (int) value;
                }
 
-               public TypeCode GetTypeCode ()
+               public static bool IsInfinity (float f)
                {
-                       return TypeCode.Single;
+                       return (f == PositiveInfinity || f == NegativeInfinity);
+               }
+
+               public static bool IsNaN (float f)
+               {
+                       return (f != f);
+               }
+
+               public static bool IsNegativeInfinity (float f)
+               {
+                       return (f < 0.0f && (f == NegativeInfinity || f == PositiveInfinity));
+               }
+
+               public static bool IsPositiveInfinity (float f)
+               {
+                       return (f > 0.0f && (f == NegativeInfinity || f == PositiveInfinity));
                }
 
                public static float Parse (string s)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), null);
                }
 
                public static float Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), fp);
+               }
+               
+               public static float Parse (string s, NumberStyles style)
+               {
+                       return Parse (s, style, null);
                }
 
                public static float Parse (string s, NumberStyles style, IFormatProvider fp)
@@ -70,21 +87,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString(null, null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString(null, fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString(format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -92,5 +105,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // ============= IConvertible Methods ============ //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.Single;
+               }
        }
 }
index b8c025d179784bc1cf469f1f1adb2a7dff7744e7..9c164709df9297ed6e5c258199723fc44a1efba6 100644 (file)
@@ -11,9 +11,9 @@ using System.Globalization;
 
 namespace System {
        
-       public struct UInt16 : IComparable, IFormattable {
-               public const ushort MinValue = 0;
+       public struct UInt16 : IComparable, IFormattable { //, IConvertible {
                public const ushort MaxValue = 0xffff;
+               public const ushort MinValue = 0;
                
                public ushort value;
 
@@ -38,21 +38,19 @@ namespace System {
                        return value;
                }
 
-               public TypeCode GetTypeCode ()
+               public static ushort Parse (string s)
                {
-                       return TypeCode.UInt16;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
-               public static ushort Parse (string s)
+               public static ushort Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
-               public static ushort Parse (string s, IFormatProvider fp)
+               public static ushort Parse (string s, NumberStyles style)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, style, null);
                }
 
                public static ushort Parse (string s, NumberStyles style, IFormatProvider fp)
@@ -63,21 +61,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -85,5 +79,11 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.UInt16;
+               }
        }
 }
index c65744d9def06a7eb984bd65ff070fc4b3f0ff99..053d81e4eaf04f8fd2148775b4a9ec49fa4c6618 100644 (file)
@@ -11,9 +11,9 @@ using System.Globalization;
 
 namespace System {
        
-       public struct UInt32 : IComparable, IFormattable {
-               public const uint MinValue = 0;
+       public struct UInt32 : IComparable, IFormattable { //, IConvertible {
                public const uint MaxValue = 0xffffffff;
+               public const uint MinValue = 0;
                
                public uint value;
 
@@ -44,23 +44,21 @@ namespace System {
                        return (int) value;
                }
 
-               public TypeCode GetTypeCode ()
-               {
-                       return TypeCode.UInt32;
-               }
-
                public static uint Parse (string s)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
                public static uint Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
+               public static uint Parse (string s, NumberStyles style)
+               {
+                       return Parse (s, style, null);
+               }
+               
                public static uint Parse (string s, NumberStyles style, IFormatProvider fp)
                {
                        // TODO: Implement me
@@ -69,21 +67,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -91,5 +85,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.UInt32;
+               }                               
        }
 }
index 1008bbe684d56dbffb18437657afe38e60a48cc3..14960c148577b14a39d7a8f6cade0ce932e6b561 100644 (file)
@@ -11,9 +11,9 @@ using System.Globalization;
 
 namespace System {
        
-       public struct UInt64 : IComparable, IFormattable {
-               public const ulong MinValue = 0;
+       public struct UInt64 : IComparable, IFormattable { //, IConvertible {
                public const ulong MaxValue = 0xffffffffffffffff;
+               public const ulong MinValue = 0;
                
                public ulong value;
 
@@ -44,21 +44,19 @@ namespace System {
                        return (int)(value & 0xffffffff) ^ (int)(value >> 32);
                }
 
-               public TypeCode GetTypeCode ()
+               public static ulong Parse (string s)
                {
-                       return TypeCode.UInt64;
+                       return Parse (s, NumberStyles.Integer, null);
                }
 
-               public static ulong Parse (string s)
+               public static ulong Parse (string s, IFormatProvider fp)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, NumberStyles.Integer, fp);
                }
 
-               public static ulong Parse (string s, IFormatProvider fp)
+               public static ulong Parse (string s, NumberStyles style)
                {
-                       // TODO: Implement me
-                       return 0;
+                       return Parse (s, style, null);
                }
 
                public static ulong Parse (string s, NumberStyles style, IFormatProvider fp)
@@ -69,21 +67,17 @@ namespace System {
 
                public override string ToString ()
                {
-                       // TODO: Implement me
-
-                       return "";
+                       return ToString ("G", null);
                }
 
                public string ToString (IFormatProvider fp)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString ("G", fp);
                }
 
                public string ToString (string format)
                {
-                       // TODO: Implement me.
-                       return "";
+                       return ToString (format, null);
                }
 
                public string ToString (string format, IFormatProvider fp)
@@ -91,5 +85,12 @@ namespace System {
                        // TODO: Implement me.
                        return "";
                }
+
+               // =========== IConvertible Methods =========== //
+
+               public TypeCode GetTypeCode ()
+               {
+                       return TypeCode.UInt64;
+               }
        }
 }
index 33a6eca6f11c9703b7ef2d0a868edde75d261a39..b7eed7ec1e6d15c02d77583703ea702ba1ef54e3 100644 (file)
@@ -1,5 +1,5 @@
 DIRS=corlib System System.XML
-CSC=//c/winnt/microsoft.net/framework/v1.0.2914/csc.exe
+CSC=$(SYSTEMROOT)/microsoft.net/framework/v1.0.2914/csc.exe
 
 all:
        @echo "You must use 'make windows' or 'make unix'."
index c431a0b89ec225f13bba8da227f34b4ca2f3377e..e7b2f4f553fb3797d7b49468f6c418d7c5062310 100755 (executable)
@@ -1,4 +1,4 @@
-CSC=//c/winnt/microsoft.net/framework/v1.0.2914/csc.exe
+CSC=$(SYSTEMROOT)/microsoft.net/framework/v1.0.2914/csc.exe
 CSCFLAGS=/nologo /debug+ /debug:full 
 
 VERSION=0.13