mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
updated for version 7.3.1159
Problem: The round() function is not always available. (Christ van Willegen) Solution: Use the solution from f_round().
This commit is contained in:
14
src/eval.c
14
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user