Re: [Mono-dev] Patch for Math.cs and MathTest.cs

2007-03-16 Thread Andreas Nahr
Locale.GetText (The value ' + mode + ' is not valid for this usage of the
type MidpointRounding.)

That is not going to work, because you would have to localize every possible
concatenated string combination. Moreover tools wouldn't be able to extract
the neccessary string data.

If there is no problem with recursive calls you can use String.Format.

Greetings

Andreas


  _  

Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Im Auftrag von Dennis
Hayes
Gesendet: Donnerstag, 15. März 2007 22:55
An: mono-devel-list@lists.ximian.com
Betreff: [Mono-dev] Patch for Math.cs and MathTest.cs


Math.cs
Added Locale.GetText to all strings.
Rearranged Rounding with MidPoint to minimize compairs, and to clean up
a bit.
 
MathTest.cs
Added quite a few new tests for rounding, including test for
the 2.0 rounding with midpoint.
It also incudes new test for veryfing bad enum execptions.
 
6 of the test are commented out because they fail.
3 fail because they have not been implmented.
1 fails due to a know rounding error already in bugzilla (new
test to exercise bug 60227  63902 should return 3.45, not
3.450...
 2 fail for what looks like a different error. 
//fails. Should return 2.6, but actualy returns 2.5
//AssertEquals(Decmial Rounding toEven, 2.6D , Math.Round(2.55D, 1));
Bug 60227 covers a number of rounding errors, it was not clear of it
included this one or not.
 
If these are good, please check them it. Otherwise let me know what is
wrong.
 
Thanks,
Dennis


  _  

No need to miss a message. Get email
http://us.rd.yahoo.com/evt=43910/*http://mobile.yahoo.com/mail on-the-go 
with Yahoo! Mail for Mobile. Get
http://us.rd.yahoo.com/evt=43910/*http://mobile.yahoo.com/mail started.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Patch for Math.cs and MathTest.cs

2007-03-16 Thread Miguel de Icaza
Hello,

 Locale.GetText (The value ' + mode + ' is not valid for this usage
 of the type MidpointRounding.)
 
 That is not going to work, because you would have to localize every
 possible concatenated string combination. Moreover tools wouldn't be
 able to extract the neccessary string data.

Yup, the above code should be:

String.Format (Locale.GetText (The value {0} is not valid for this
usage of the type MidpointRounding), mode);

 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Patch for Math.cs and MathTest.cs

2007-03-16 Thread Andreas Nahr
Locale.GetText even has a Locale.GetText(String formatString, Object[]
params) convenience overload.

Greetings
Andreas 

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Im Auftrag von Miguel de
Icaza
Gesendet: Freitag, 16. März 2007 17:50
An: Andreas Nahr
Cc: 'Dennis Hayes'; mono-devel-list@lists.ximian.com
Betreff: Re: [Mono-dev] Patch for Math.cs and MathTest.cs

Hello,

 Locale.GetText (The value ' + mode + ' is not valid for this usage 
 of the type MidpointRounding.)
 
 That is not going to work, because you would have to localize every 
 possible concatenated string combination. Moreover tools wouldn't be 
 able to extract the neccessary string data.

Yup, the above code should be:

String.Format (Locale.GetText (The value {0} is not valid for this
usage of the type MidpointRounding), mode);

 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Patch for Math.cs and MathTest.cs

2007-03-15 Thread Dennis Hayes
  Math.cs
  Added Locale.GetText to all strings.
  Rearranged Rounding with MidPoint to minimize compairs, and to clean up a 
bit.
   
  MathTest.cs
  Added quite a few new tests for rounding, including test for
  the 2.0 rounding with midpoint.
  It also incudes new test for veryfing bad enum execptions.
   
  6 of the test are commented out because they fail.
  3 fail because they have not been implmented.
  1 fails due to a know rounding error already in bugzilla (new
  test to exercise bug 60227  63902 should return 3.45, not 
3.450...
  
   2 fail for what looks like a different error. 
  //fails. Should return 2.6, but actualy returns 2.5
  //AssertEquals(Decmial Rounding toEven, 2.6D , Math.Round(2.55D, 1));
  Bug 60227 covers a number of rounding errors, it was not clear of it included 
this one or not.
   
  If these are good, please check them it. Otherwise let me know what is wrong.
   
  Thanks,
  Dennis


 
-
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.Index: System/ChangeLog
===
--- System/ChangeLog(revision 73984)
+++ System/ChangeLog(working copy)
@@ -1,3 +1,10 @@
+2007-03-10  Dennis Hayes  [EMAIL PROTECTED]
+
+   * Math.cs: Added Locale.GetText to execptions.
+   Rearranged Rounding with Midpoints to minimize
+   midpoint enum compairs, and slimplfy strucure a
+   bit for adding support for AwayFromZero enum.
+
 2007-03-08  Gert Driesen  [EMAIL PROTECTED]
 
* StringComparer.cs: Renamed StringComparer classes and promoted them
Index: System/Math.cs
===
--- System/Math.cs  (revision 73984)
+++ System/Math.cs  (working copy)
@@ -1,4 +1,4 @@
-//
+//
 // System.Math.cs
 //
 // Authors:
@@ -373,23 +373,26 @@
[MonoTODO (Not implemented)]
public static decimal Round (decimal d, MidpointRounding mode)
{
-   if ((mode != MidpointRounding.ToEven)  (mode != 
MidpointRounding.AwayFromZero))
-   throw new ArgumentException (The value ' + 
mode + ' is not valid for this usage of the type MidpointRounding., mode);
-
if (mode == MidpointRounding.ToEven)
return Round (d);
-   throw new NotImplementedException ();
+   
+   if (mode == MidpointRounding.AwayFromZero)
+   throw new NotImplementedException ();
+   
+   throw new ArgumentException (Locale.GetText (The value 
' + mode + ' is not valid for this usage of the type MidpointRounding.), 
mode);
+
}
 
[MonoTODO (Not implemented)]
public static decimal Round (decimal d, int decimals, 
MidpointRounding mode)
{
-   if ((mode != MidpointRounding.ToEven)  (mode != 
MidpointRounding.AwayFromZero))
-   throw new ArgumentException (The value ' + 
mode + ' is not valid for this usage of the type MidpointRounding., mode);
-
if (mode == MidpointRounding.ToEven)
return Round (d, decimals);
-   throw new NotImplementedException ();
+   
+   if (mode == MidpointRounding.AwayFromZero)
+   throw new NotImplementedException ();
+   
+   throw new ArgumentException (Locale.GetText (The value 
' + mode + ' is not valid for this usage of the type MidpointRounding.), 
mode);
}
 #endif
 
@@ -411,26 +414,31 @@
 #if NET_2_0
public static double Round (double value, MidpointRounding mode)
{
-   if ((mode != MidpointRounding.ToEven)  (mode != 
MidpointRounding.AwayFromZero))
-   throw new ArgumentException (The value ' + 
mode + ' is not valid for this usage of the type MidpointRounding., mode);
-
if (mode == MidpointRounding.ToEven)
return Round (value);
-   if (value  0)
-   return Floor (value + 0.5);
-   else
-   return Ceiling (value - 0.5);
+   
+   if (mode == MidpointRounding.AwayFromZero)
+   {
+   if (value  0)
+   return Floor (value + 0.5);
+   else
+   return Ceiling (value - 0.5);
+   }
+
+   throw new ArgumentException (Locale.GetText (The