X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fnasal%2Fmathlib.c;h=f2434b3cfe1dafe38cdfeba827716d8b91c1dc66;hb=e036dfc5bf691e2cb467f27010c3291f5b1c13a7;hp=fcf23e6e0ffdf8439cd5c3628f0de66afbb4a5e0;hpb=ad83e70cf5983c7b307847aa2cb92c40e42bc534;p=simgear.git diff --git a/simgear/nasal/mathlib.c b/simgear/nasal/mathlib.c index fcf23e6e..f2434b3c 100644 --- a/simgear/nasal/mathlib.c +++ b/simgear/nasal/mathlib.c @@ -155,12 +155,20 @@ static naRef f_round(naContext c, naRef me, int argc, naRef* args) { naRef a = naNumValue(argc > 0 ? args[0] : naNil()); naRef b = naNumValue(argc > 1 ? args[1] : naNil()); +#ifdef _MSC_VER + double x,y; +#endif if(naIsNil(a)) naRuntimeError(c, "non numeric arguments to round()"); if (naIsNil(b)) b.num = 1.0; - + +#ifdef _MSC_VER // MSVC is not C99-compatible, no round() in math.h + y = a.num / b.num; + x = floor(y + 0.5); +#else double x = round(a.num / b.num); +#endif a.num = x * b.num; return VALIDATE(a);