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

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

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private/NumberFormat C


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private/NumberFormat CustomFormatter.cs,1.3,1.4 Formatter.cs,1.5,1.6 GeneralFormatter.cs,1.7,1.8 RoundTripFormatter.cs,1.3,1.4 ScientificFormatter.cs,1.5,1.6
Date: Tue, 15 Apr 2003 03:27:56 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat
In directory subversions:/tmp/cvs-serv27699/runtime/System/Private/NumberFormat

Modified Files:
        CustomFormatter.cs Formatter.cs GeneralFormatter.cs 
        RoundTripFormatter.cs ScientificFormatter.cs 
Log Message:


Mark up members of the "ExtendedNumerics" subset of ECMA with
CONFIG_EXTENDED_NUMERICS.


Index: CustomFormatter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** CustomFormatter.cs  29 Nov 2002 00:58:38 -0000      1.3
--- CustomFormatter.cs  15 Apr 2003 07:27:54 -0000      1.4
***************
*** 323,326 ****
--- 323,327 ----
        }
  
+ #if CONFIG_EXTENDED_NUMERICS
        private string FormatScientific(double d, string format, int sign,
                                                                                
                        IFormatProvider provider)
***************
*** 370,373 ****
--- 371,375 ----
                return ret.ToString();
        }
+ #endif // CONFIG_EXTENDED_NUMERICS
  
        private string FormatInteger(ulong value, string format, int sign,
***************
*** 379,382 ****
--- 381,385 ----
  
  
+ #if CONFIG_EXTENDED_NUMERICS
        private string FormatFloat(double d, string format, int sign,
                                                                                
                IFormatProvider provider)
***************
*** 419,422 ****
--- 422,426 ----
                }
        }
+ #endif // CONFIG_EXTENDED_NUMERICS
  
        //
***************
*** 428,442 ****
                {
                        long val = OToLong(o);
!                       string format = FormatFromSign(Math.Sign(val));
                        if (ScientificStart(format) == -1)
                        {
!                               return FormatInteger((ulong)Math.Abs(val),
!                                               format, Math.Sign(val), 
provider);
                        }
                        else
                        {
!                               return FormatScientific((double)Math.Abs(val),
!                                               format, Math.Sign(val), 
provider);
                        }
                }
                else if (IsUnsignedInt(o))
--- 432,462 ----
                {
                        long val = OToLong(o);
!                       int sign;
!                       if(val < 0)
!                       {
!                               sign = -1;
!                               val = -val;
!                       }
!                       else if(val > 0)
!                       {
!                               sign = 1;
!                       }
!                       else
!                       {
!                               sign = 0;
!                       }
!                       string format = FormatFromSign(sign);
!               #if CONFIG_EXTENDED_NUMERICS
                        if (ScientificStart(format) == -1)
                        {
!                               return FormatInteger((ulong)val, format, sign, 
provider);
                        }
                        else
                        {
!                               return FormatScientific((double)val, format, 
sign, provider);
                        }
+               #else
+                       return FormatInteger((ulong)val, format, sign, 
provider);
+               #endif
                }
                else if (IsUnsignedInt(o))
***************
*** 445,448 ****
--- 465,469 ----
                        string format = ( (val==0) ? zeroFormat : 
positiveFormat);
  
+               #if CONFIG_EXTENDED_NUMERICS
                        if (ScientificStart(format) == -1)
                        {
***************
*** 454,458 ****
--- 475,483 ----
                                                format, val == 0 ? 0 : 1, 
provider);
                        }
+               #else
+                       return FormatInteger(val, format, val == 0 ? 0 : 1, 
provider);
+               #endif
                }
+ #if CONFIG_EXTENDED_NUMERICS
                else if (IsFloat(o))
                {
***************
*** 485,488 ****
--- 510,514 ----
                        }
                }
+ #endif // CONFIG_EXTENDED_NUMERICS
                else if (o is IFormattable)
                {

Index: Formatter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/Formatter.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Formatter.cs        14 Apr 2003 06:04:27 -0000      1.5
--- Formatter.cs        15 Apr 2003 07:27:54 -0000      1.6
***************
*** 83,86 ****
--- 83,87 ----
        }
        
+ #if CONFIG_EXTENDED_NUMERICS
        static protected bool IsFloat(Object o)
        {
***************
*** 157,160 ****
--- 158,162 ----
                return ret;
        }
+ #endif // CONFIG_EXTENDED_NUMERICS
  
        static protected ulong OToUlong(Object o)
***************
*** 201,204 ****
--- 203,207 ----
                        ret = (ulong)o;
                }
+ #if CONFIG_EXTENDED_NUMERICS
                else if (o is Single)
                {
***************
*** 216,219 ****
--- 219,223 ----
                        ret = (ulong)n;
                }
+ #endif
                else
                {
***************
*** 266,269 ****
--- 270,274 ----
                        ret = (long)n;
                }
+ #if CONFIG_EXTENDED_NUMERICS
                else if (o is Single)
                {
***************
*** 281,284 ****
--- 286,290 ----
                        ret = (long)n;
                }
+ #endif
                else
                {
***************
*** 302,305 ****
--- 308,312 ----
                        ret = Formatter.FormatInteger(OToUlong(o));
                }
+ #if CONFIG_EXTENDED_NUMERICS
                else if (IsDecimal(o))
                {
***************
*** 358,361 ****
--- 365,369 ----
                        }
                }
+ #endif
                else
                {
***************
*** 384,387 ****
--- 392,396 ----
        }
  
+ #if CONFIG_EXTENDED_NUMERICS
        static protected string FormatDecimal(decimal value)
        {
***************
*** 466,469 ****
--- 475,479 ----
                return sb.ToString();
        }
+ #endif // CONFIG_EXTENDED_NUMERICS
  
        static protected string GroupInteger(string value, int[] groupSizes,

Index: GeneralFormatter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** GeneralFormatter.cs 3 Apr 2003 15:20:09 -0000       1.7
--- GeneralFormatter.cs 15 Apr 2003 07:27:54 -0000      1.8
***************
*** 55,61 ****
--- 55,63 ----
                if (o is Int64 || o is UInt64) return 19;
                if (o is Byte || o is SByte) return 3;
+ #if CONFIG_EXTENDED_NUMERICS
                if (o is Single) return 7;
                if (o is Double) return 15;
                if (o is Decimal) return 29;
+ #endif
                throw new FormatException(_("Format_TypeException"));
        }
***************
*** 92,95 ****
--- 94,98 ----
                }
  
+ #if CONFIG_EXTENDED_NUMERICS
                if (OToDouble(o) == 0.0d) 
                {
***************
*** 100,103 ****
--- 103,137 ----
                        exponent = (int) 
Math.Floor(Math.Log10(Math.Abs(OToDouble(o))));
                }
+ #else
+               // Determine the exponent without using floating-point.
+               if (IsSignedInt(o))
+               {
+                       long lvalue = OToLong(o);
+                       if (lvalue < 0)
+                       {
+                               lvalue = -lvalue;
+                       }
+                       exponent = 0;
+                       while(lvalue >= 10)
+                       {
+                               ++exponent;
+                               lvalue /= 10;
+                       }
+               }
+               else if (IsUnsignedInt(o))
+               {
+                       ulong ulvalue = OToUlong(o);
+                       exponent = 0;
+                       while(ulvalue >= 10)
+                       {
+                               ++exponent;
+                               ulvalue /= 10;
+                       }
+               }
+               else
+               {
+                       exponent = 0;
+               }
+ #endif
  
                if (IsSignedInt(o) || IsUnsignedInt(o))

Index: RoundTripFormatter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/RoundTripFormatter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** RoundTripFormatter.cs       14 Apr 2003 06:04:27 -0000      1.3
--- RoundTripFormatter.cs       15 Apr 2003 07:27:54 -0000      1.4
***************
*** 36,39 ****
--- 36,40 ----
        public override string Format(Object o, IFormatProvider provider)
        {
+ #if CONFIG_EXTENDED_NUMERICS
                //  Calculate precision
                int precision;
***************
*** 65,68 ****
--- 66,72 ----
  
                return ret.ToString();
+ #else
+               throw new FormatException(_("Format_TypeException"));
+ #endif
        }               
  } // class RoundTripFormatter

Index: ScientificFormatter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ScientificFormatter.cs      14 Apr 2003 06:04:27 -0000      1.5
--- ScientificFormatter.cs      15 Apr 2003 07:27:54 -0000      1.6
***************
*** 41,44 ****
--- 41,45 ----
        public override string Format(Object o, IFormatProvider provider)
        {
+ #if CONFIG_EXTENDED_NUMERICS
                bool isNegative = false;
  
***************
*** 117,120 ****
--- 118,124 ----
  
                return ret.ToString();
+ #else // !CONFIG_EXTENDED_NUMERICS
+               return String.Empty;
+ #endif // !CONFIG_EXTENDED_NUMERICS
        }               
  } // class ScientificFormatter





reply via email to

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