Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(856)

Unified Diff: runtime/platform/c99_support_win.cc

Issue 11411188: Fix floating point issues on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moved round() back to c99_support_win. Cleaned up the code, added comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/platform/c99_support_win.cc
diff --git a/runtime/platform/c99_support_win.cc b/runtime/platform/c99_support_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..00864c009748e5a18f504eaa72fc59a1bde770af
--- /dev/null
+++ b/runtime/platform/c99_support_win.cc
@@ -0,0 +1,24 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
Mads Ager (google) 2012/11/28 09:26:26 Just move your new implementation to c99_support_w
aam-me 2012/11/28 12:14:36 Done.
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include <math.h>
+
+#include "platform/c99_support_win.h"
+
+double round(double x) {
+ if (!_finite(x)) {
+ return x;
+ }
+
+ double intpart;
+ double fractpart = modf(x, &intpart);
+
+ if (fractpart >= 0.5) {
+ return intpart + 1;
+ } else if (fractpart > -0.5) {
+ return intpart;
+ } else {
+ return intpart - 1;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698