[Mono-bugs] [Bug 399389] DateTime.AddMilliseconds should round to nearest integer

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Feb 10 17:28:44 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=399389

User gonzalo at novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=399389#c1


Gonzalo Paniagua Javier <gonzalo at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gonzalo at novell.com




--- Comment #1 from Gonzalo Paniagua Javier <gonzalo at novell.com>  2009-02-10 15:28:43 MST ---
Fixing this with the following patch breaks 7 tests in corlib... I don't know
if those pass on windows...


Index: DateTime.cs
===================================================================
--- DateTime.cs    (revision 126520)
+++ DateTime.cs    (working copy)
@@ -575,12 +575,12 @@

         public DateTime AddMilliseconds (double value)
         {
-            if ((value * TimeSpan.TicksPerMillisecond) > long.MaxValue ||
-                    (value * TimeSpan.TicksPerMillisecond) < long.MinValue) {
+            value = Math.Round (value);
+            double v2 = value * TimeSpan.TicksPerMillisecond;
+            if (v2 > long.MaxValue || v2 < long.MinValue)
                 throw new ArgumentOutOfRangeException();
-            }
-            long msticks = (long) (value * TimeSpan.TicksPerMillisecond);

+            long msticks = (long) v2;
             return AddTicks (msticks);
         }

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list