[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private/NumberFormat C
From: |
Jonathan Springer <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private/NumberFormat CustomFormatter.cs,1.1,1.2 FixedPointFormatter.cs,1.1,1.2 GeneralFormatter.cs,1.1,1.2 NumberFormatter.cs,1.1,1.2 PercentFormatter.cs,1.1,1.2 ScientificFormatter.cs,1.1,1.2 |
Date: |
Wed, 27 Nov 2002 15:29:58 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat
In directory subversions:/tmp/cvs-serv28145/runtime/System/Private/NumberFormat
Modified Files:
CustomFormatter.cs FixedPointFormatter.cs GeneralFormatter.cs
NumberFormatter.cs PercentFormatter.cs ScientificFormatter.cs
Log Message:
Range-checking fixes from Rich's tests.
Index: CustomFormatter.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/CustomFormatter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** CustomFormatter.cs 27 Nov 2002 14:37:27 -0000 1.1
--- CustomFormatter.cs 27 Nov 2002 20:29:56 -0000 1.2
***************
*** 159,163 ****
// Scaling
int formatindex = decimalPos - 1;
! while (format[formatindex] == groupSeparator)
{
scale += 3;
--- 159,163 ----
// Scaling
int formatindex = decimalPos - 1;
! while (formatindex >=0 && format[formatindex] == groupSeparator)
{
scale += 3;
***************
*** 165,198 ****
}
! if (scale > 0)
{
! // Move the decimal point
! StringBuilder temp
! = new
StringBuilder(value.Substring(0,value.IndexOf('.')));
! if (temp.Length < scale)
! {
! temp.Insert(0,"0",scale - temp.Length);
! }
! temp.Insert(temp.Length - scale,'.');
! temp.Append(value.Substring(value.IndexOf('.')+1));
! if (includeNegSign && sign == -1)
! {
! temp.Insert(0,
NumberFormatInfo(provider).NegativeSign);
! }
! rawnumber = temp.ToString();
}
! else
{
! if (includeNegSign && sign == -1)
! {
! StringBuilder temp = new StringBuilder(value);
!
temp.Insert(0,NumberFormatInfo(provider).NegativeSign);
! rawnumber = temp.ToString();
! }
! else
! {
! rawnumber = value;
! }
}
// Formatting
--- 165,190 ----
}
! // Move the decimal point
! StringBuilder temp = new StringBuilder();
! if (scale <= value.IndexOf('.'))
! {
! temp.Append(value.Substring(0, value.IndexOf('.') -
scale))
! .Append(".")
!
.Append(value.Substring(value.IndexOf('.') - scale, scale));
! }
! else
{
! temp.Append(".")
! .Append(value
! .Substring(0,
value.IndexOf('.'))
! .PadLeft(scale, '0'));
}
! temp.Append(value.Substring(value.IndexOf('.') + 1));
!
! if (includeNegSign && sign == -1)
{
! temp.Insert(0, NumberFormatInfo(provider).NegativeSign);
}
+ rawnumber = temp.ToString();
// Formatting
***************
*** 240,244 ****
if (rawindex >= 0)
{
! ret.Insert(0, rawnumber.Substring(0,rawindex));
}
--- 232,236 ----
if (rawindex >= 0)
{
! ret.Insert(0, rawnumber.Substring(0, rawindex+1));
}
***************
*** 252,256 ****
|| format[formatindex] ==
zeroPlaceholder)
{
! ret.Insert(0,'0');
}
else if (format[formatindex] == groupSeparator)
--- 244,248 ----
|| format[formatindex] ==
zeroPlaceholder)
{
! ret.Insert(0, '0');
}
else if (format[formatindex] == groupSeparator)
***************
*** 341,346 ****
// Format the mantissa
StringBuilder ret = new StringBuilder(
! FormatFloat(mantissa, format.Substring(1, i),
sign, provider)
! +
format[i++]);
// Sign logic
--- 333,338 ----
// Format the mantissa
StringBuilder ret = new StringBuilder(
! FormatFloat(mantissa, format.Substring(0, i),
sign, provider))
! .Append(format[i++]);
// Sign logic
***************
*** 409,413 ****
}
! return FormatRawNumber( Formatter.FormatFloat(d, precision+2),
format, sign, provider);
}
--- 401,405 ----
}
! return FormatRawNumber( Formatter.FormatFloat(d, precision +
2),
format, sign, provider);
}
Index: FixedPointFormatter.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/FixedPointFormatter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FixedPointFormatter.cs 27 Nov 2002 14:37:27 -0000 1.1
--- FixedPointFormatter.cs 27 Nov 2002 20:29:56 -0000 1.2
***************
*** 56,67 ****
else
{
!
ret.Append(rawnumber.Substring(0,rawnumber.IndexOf('.')));
}
if (precision > 0)
{
!
ret.Append(NumberFormatInfo(provider).NumberDecimalSeparator);
! ret.Append(
!
rawnumber.Substring(rawnumber.IndexOf('.')+1, precision));
}
--- 56,68 ----
else
{
! ret.Append(rawnumber.Substring(0,
rawnumber.IndexOf('.')));
}
if (precision > 0)
{
!
ret.Append(NumberFormatInfo(provider).NumberDecimalSeparator)
! .Append(rawnumber
!
.PadRight(rawnumber.IndexOf('.')+1+precision, '0')
!
.Substring(rawnumber.IndexOf('.')+1, precision));
}
Index: GeneralFormatter.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/GeneralFormatter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** GeneralFormatter.cs 27 Nov 2002 14:37:27 -0000 1.1
--- GeneralFormatter.cs 27 Nov 2002 20:29:56 -0000 1.2
***************
*** 81,85 ****
{
return
! new ScientificFormatter(precision,
Ee).Format(o, provider);
}
}
--- 81,85 ----
{
return
! new ScientificFormatter(-1,
Ee).Format(o, provider);
}
}
Index: NumberFormatter.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/NumberFormatter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** NumberFormatter.cs 27 Nov 2002 14:37:27 -0000 1.1
--- NumberFormatter.cs 27 Nov 2002 20:29:56 -0000 1.2
***************
*** 106,112 ****
if (precision > 0)
{
!
ret.Append(NumberFormatInfo(provider).NumberDecimalSeparator);
! ret.Append(
! rawnumber.Substring(rawnumber.IndexOf('.')+1,
precision));
}
--- 106,113 ----
if (precision > 0)
{
!
ret.Append(NumberFormatInfo(provider).NumberDecimalSeparator)
! .Append(rawnumber
!
.PadRight(rawnumber.IndexOf('.')+1+precision,'0')
! .Substring(rawnumber.IndexOf('.')+1,
precision));
}
Index: PercentFormatter.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/PercentFormatter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PercentFormatter.cs 27 Nov 2002 14:37:27 -0000 1.1
--- PercentFormatter.cs 27 Nov 2002 20:29:56 -0000 1.2
***************
*** 119,125 ****
if (precision > 0)
{
!
ret.Append(NumberFormatInfo(provider).PercentDecimalSeparator);
! ret.Append(
! rawnumber.Substring(rawnumber.IndexOf('.')+1,
precision));
}
--- 119,126 ----
if (precision > 0)
{
!
ret.Append(NumberFormatInfo(provider).PercentDecimalSeparator)
! .Append(rawnumber
!
.PadRight(rawnumber.IndexOf('.')+1 + precision, '0')
!
.Substring(rawnumber.IndexOf('.')+1, precision));
}
Index: ScientificFormatter.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberFormat/ScientificFormatter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ScientificFormatter.cs 27 Nov 2002 14:37:27 -0000 1.1
--- ScientificFormatter.cs 27 Nov 2002 20:29:56 -0000 1.2
***************
*** 35,39 ****
public ScientificFormatter(int precision, char Ee)
{
! this.precision = precision == -1 ? 6 : 0;
this.Ee = Ee;
}
--- 35,39 ----
public ScientificFormatter(int precision, char Ee)
{
! this.precision = precision == -1 ? 6 : precision;
this.Ee = Ee;
}
***************
*** 64,71 ****
rawnumber = FormatFloat(mantissa, precision);
! ret = new StringBuilder(
! rawnumber.Substring(0,rawnumber.IndexOf('.')) +
!
NumberFormatInfo(provider).NumberDecimalSeparator +
! rawnumber.Substring(rawnumber.IndexOf('.')+1));
if (isNegative)
--- 64,75 ----
rawnumber = FormatFloat(mantissa, precision);
! ret = new StringBuilder(
! rawnumber.Substring(0, rawnumber.IndexOf('.')));
!
! if (precision > 0)
! {
!
ret.Append(NumberFormatInfo(provider).NumberDecimalSeparator)
!
.Append(rawnumber.Substring(rawnumber.IndexOf('.')+1));
! }
if (isNegative)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private/NumberFormat CustomFormatter.cs,1.1,1.2 FixedPointFormatter.cs,1.1,1.2 GeneralFormatter.cs,1.1,1.2 NumberFormatter.cs,1.1,1.2 PercentFormatter.cs,1.1,1.2 ScientificFormatter.cs,1.1,1.2,
Jonathan Springer <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet/codegen cg_arith.tc,1.14,1.15
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet/samples I18N.CJK.dll,1.20,1.21 I18N.MidEast.dll,1.20,1.21 I18N.Other.dll,1.20,1.21 I18N.Rare.dll,1.20,1.21 I18N.West.dll,1.20,1.21 I18N.dll,1.21,1.22 System.Xml.dll,1.18,1.19 System.dll,1.22,1.23 mscorlib.dll,1.91,1.92
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet/codegen cg_arith.tc,1.14,1.15
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet/samples I18N.CJK.dll,1.20,1.21 I18N.MidEast.dll,1.20,1.21 I18N.Other.dll,1.20,1.21 I18N.Rare.dll,1.20,1.21 I18N.West.dll,1.20,1.21 I18N.dll,1.21,1.22 System.Xml.dll,1.18,1.19 System.dll,1.22,1.23 mscorlib.dll,1.91,1.92
- Index(es):