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


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private/NumberFormat HexadecimalFormatter.cs, 1.3, 1.4
Date: Sun, 20 Jul 2003 14:47:04 -0400

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

Modified Files:
        HexadecimalFormatter.cs 
Log Message:
Fixes bug #3050 ..


Index: HexadecimalFormatter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/HexadecimalFormatter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** HexadecimalFormatter.cs     2 Feb 2003 16:39:18 -0000       1.3
--- HexadecimalFormatter.cs     20 Jul 2003 18:47:02 -0000      1.4
***************
*** 36,39 ****
--- 36,40 ----
        //  Return values.
        private char[] digits;
+       private int minPrecision;
  
        public HexadecimalFormatter(int precision, char format)
***************
*** 59,65 ****
                if (value >= 0) return s.ToString();
  
!               while (s[0] == digits[15]) s.Remove(0,1);
! 
!               return s.ToString().PadLeft(precision, digits[15]);
        }
  
--- 60,70 ----
                if (value >= 0) return s.ToString();
  
!               while (s.Length!=0 && s[0] == digits[15]) s.Remove(0,1);
!               
!               // Hex needs a minimum precision ie (-1).ToString("X")
!               // becomes FFFFFFFF instead of being just F
!               return s.ToString().PadLeft(
!                               precision > minPrecision ? precision : 
minPrecision , 
!                               digits[15]);
        }
  
***************
*** 77,84 ****
--- 82,99 ----
                return buf.ToString().PadLeft(precision, '0');
        }
+       
+       private static int PrecisionOf(Object o) 
+       {
+               if (o is Int16 || o is UInt16) return 4;
+               if (o is Int32 || o is UInt32) return 8;
+               if (o is Int64 || o is UInt64) return 16;
+               if (o is Byte || o is SByte) return 2;
+               throw new FormatException(_("Format_TypeException"));
+       }
  
        public override string Format(Object o, IFormatProvider provider)
        {
                long value;
+               minPrecision=PrecisionOf(o);
  
                //  Type validation





reply via email to

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