[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private NumberParser.
From: |
Jonathan Springer <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private NumberParser.cs,1.6,1.7 |
Date: |
Thu, 16 Jan 2003 20:08:48 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private
In directory subversions:/tmp/cvs-serv31032/runtime/System/Private
Modified Files:
NumberParser.cs
Log Message:
Floating point Parse/ToString fixes.
Index: NumberParser.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/NumberParser.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** NumberParser.cs 10 Jan 2003 23:33:31 -0000 1.6
--- NumberParser.cs 17 Jan 2003 01:08:45 -0000 1.7
***************
*** 1107,1111 ****
// Parse up to the decimal
! double work = (double)EatDigits(sb);
// Parse after the decimal
--- 1107,1117 ----
// Parse up to the decimal
! double work;
! while (sb.Length > 0 && sb[0] >= '0' && sb[0] <= '9')
! {
! work *= 10;
! work += (uint)(sb[0] - '0');
! sb.Remove(0, 1);
! }
// Parse after the decimal
***************
*** 1115,1123 ****
uint fracDigits;
sb.Remove(0, nfi.NumberDecimalSeparator.Length);
! fracDigits = EatDigits(sb);
! if (fracDigits != 0)
{
! work += (double)fracDigits *
! Math.Pow(10,
-Math.Floor(Math.Log10(fracDigits)) -1) ;
}
}
--- 1121,1130 ----
uint fracDigits;
sb.Remove(0, nfi.NumberDecimalSeparator.Length);
! for (int i = -1;
! sb.Length > 0 && sb[0] >= '0' && sb[0]
<= '9' ;
! i--)
{
! work += (uint)(sb[0] - '0') * Math.Pow(10, i);
! sb.Remove(0, 1);
}
}
***************
*** 1126,1130 ****
if (sb.Length > 0 && (sb[0] == 'e' || sb[0] == 'E') )
{
! uint exponent;
bool negExponent = false;
sb.Remove(0, 1);
--- 1133,1137 ----
if (sb.Length > 0 && (sb[0] == 'e' || sb[0] == 'E') )
{
! uint exponent = 0;
bool negExponent = false;
sb.Remove(0, 1);
***************
*** 1143,1151 ****
throw new
FormatException(_("Format_ExponentRequiresSign"));
}
! exponent = EatDigits(sb);
! if (exponent != 0)
{
! work *= Math.Pow(10, exponent * (negExponent ?
-1 : 1));
}
}
--- 1150,1162 ----
throw new
FormatException(_("Format_ExponentRequiresSign"));
}
!
! while (sb.Length > 0 && sb[0] >= '0' && sb[0] <= '9')
{
! exponent *= 10;
! exponent += (uint)(sb[0] - '0');
! sb.Remove(0, 1);
}
+
+ work *= Math.Pow(10, exponent * (negExponent ? -1 : 1));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Private NumberParser.cs,1.6,1.7,
Jonathan Springer <address@hidden> <=