diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-06-10 20:10:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-06-10 20:10:44 +0200 |
commit | a2e14fc764c306cc33fe174707756be70f883319 (patch) | |
tree | 65543c6ab65e37ffb103689045600c18a62e84dc /src/eval.c | |
parent | 0bdda37fb4b8118ec4bd797eddca9eaf5d3b381d (diff) | |
download | vim-git-a2e14fc764c306cc33fe174707756be70f883319.tar.gz |
updated for version 7.3.1159v7.3.1159
Problem: The round() function is not always available. (Christ van
Willegen)
Solution: Use the solution from f_round().
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c index 7250556fc..38893c795 100644 --- a/src/eval.c +++ b/src/eval.c @@ -15774,6 +15774,17 @@ theend: } #ifdef FEAT_FLOAT + +/* + * round() is not in C90, use ceil() or floor() instead. + */ + float_T +vim_round(f) + float_T f; +{ + return f > 0 ? floor(f + 0.5) : ceil(f - 0.5); +} + /* * "round({float})" function */ @@ -15786,8 +15797,7 @@ f_round(argvars, rettv) rettv->v_type = VAR_FLOAT; if (get_float_arg(argvars, &f) == OK) - /* round() is not in C90, use ceil() or floor() instead. */ - rettv->vval.v_float = f > 0 ? floor(f + 0.5) : ceil(f - 0.5); + rettv->vval.v_float = vim_round(f); else rettv->vval.v_float = 0.0; } |