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

Unified Diff: runtime/platform/c99_support_win.h

Issue 11411188: Fix floating point issues on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: ndx_x, ndx_y -> index_x, index_y. 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
« no previous file with comments | « runtime/lib/math.cc ('k') | runtime/platform/floating_point.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/c99_support_win.h
diff --git a/runtime/platform/c99_support_win.h b/runtime/platform/c99_support_win.h
index 1d09eff6a7b7843931c4d5b026f24bd918f873d7..10fcf2bec1e9cd16042e2f09a5546b4d85d038fc 100644
--- a/runtime/platform/c99_support_win.h
+++ b/runtime/platform/c99_support_win.h
@@ -48,10 +48,19 @@ static inline double trunc(double x) {
}
static inline double round(double x) {
- if (x < 0) {
- return ceil(x - 0.5);
+ 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 floor(x + 0.5);
+ return intpart - 1;
}
}
« no previous file with comments | « runtime/lib/math.cc ('k') | runtime/platform/floating_point.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698