dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Private/Number...


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Private/Number...
Date: Thu, 07 Sep 2006 10:42:50 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Changes by:     Heiko Weiss <brubbel>   06/09/07 10:42:49

Modified files:
        .              : ChangeLog 
        runtime/System/Private/NumberFormat: RoundTripFormatter.cs 

Log message:
        use general formatter for formatting since we do not support more than
        7 (Single) or 15 (Double) precision.
        Old code had bug formatting double 100.0, got 100. (with dot).
        
        maybe someone could implement a good round trip formatter.
        The formatter should try fromatting with general formatter 
        and parse it again to compare the values.
        if the values are not the same, more recision (Signle:9, double:17)
        should be used to format the value.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2433&r2=1.2434
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/Private/NumberFormat/RoundTripFormatter.cs?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2433
retrieving revision 1.2434
diff -u -b -r1.2433 -r1.2434
--- ChangeLog   1 Sep 2006 06:30:32 -0000       1.2433
+++ ChangeLog   7 Sep 2006 10:42:49 -0000       1.2434
@@ -1,3 +1,10 @@
+2006-09-07  Heiko Weiss  <address@hidden>
+
+       * runtime/System/Private/NumberFormat/RoundTripFormatter.cs: 
+       use general formatter for formatting since we do not support more than
+       7 (Single) or 15 (Double) precision.
+       Old code had bug formatting double 100.0, got 100. (with dot).
+
 2006-09-01  Heiko Weiss  <address@hidden>
 
        * runtime/System/Private/NumberFormat/Formatter.cs: use general 
formatter

Index: runtime/System/Private/NumberFormat/RoundTripFormatter.cs
===================================================================
RCS file: 
/sources/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/RoundTripFormatter.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- runtime/System/Private/NumberFormat/RoundTripFormatter.cs   15 Apr 2003 
07:27:54 -0000      1.4
+++ runtime/System/Private/NumberFormat/RoundTripFormatter.cs   7 Sep 2006 
10:42:49 -0000       1.5
@@ -36,35 +36,17 @@
        public override string Format(Object o, IFormatProvider provider)
        {
 #if CONFIG_EXTENDED_NUMERICS
-               //  Calculate precision
-               int precision;
-               if (o is Single) precision = 7;
-               else if (o is Double) precision = 15;
-               else throw new FormatException(_("Format_TypeException"));
-
-               //  Get initial number
-               string rawnumber = FormatAnyRound(o, precision, provider);
-               StringBuilder ret = new StringBuilder();
-
-               if (rawnumber[0] == '-')
-               {
-                       ret.Append(NumberFormatInfo(provider).NegativeSign);
-                       rawnumber = rawnumber.Substring(1);
-               }
-
-               //  Create portion before the decimal point
-               if (rawnumber[0] == '.') ret.Append('0');
-               else ret.Append(rawnumber.Substring(0,rawnumber.IndexOf('.')));
 
-               //  Insert decimal point
-               ret.Append(NumberFormatInfo(provider).NumberDecimalSeparator);
+               /* 
+                       round trip should check if parsing the value as string 
is the same value.
+                       if not, more precision should be used. Single 9, Double 
17.
+                       Since we do not support more than precision 7/15 use 
the GeneralFormatters.
+               */
 
-               //  Append the portion of the number following the decimal point
-               int decpt = rawnumber.IndexOf('.')+1;   
-               ret.Append(rawnumber.Substring(decpt,
-                                                               
Math.Min(rawnumber.Length-decpt, precision)));
+               if (o is Single) return ((Single)o).ToString( null, provider );
+               else if (o is Double) return ((Double)o).ToString( null, 
provider );
+               else throw new FormatException(_("Format_TypeException"));
 
-               return ret.ToString();
 #else
                throw new FormatException(_("Format_TypeException"));
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]