| 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;
|
| }
|
| }
|
|
|
|
|