vim-patch:8.0.0614

Problem:    float2nr() is not exactly right.
Solution:   Make float2nr() more accurate.  Turn test64 into a new style test.
            (Hirohito Higashi, closes vim/vim#1688)

863e80b445
This commit is contained in:
James McCoy
2017-06-06 07:34:25 -04:00
parent 9281653233
commit 6757c503bd
3 changed files with 93 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
*/
#include <assert.h>
#include <float.h>
#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
@@ -8562,9 +8563,9 @@ static void f_float2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
float_T f;
if (tv_get_float_chk(argvars, &f)) {
if (f < -VARNUMBER_MAX) {
if (f <= -VARNUMBER_MAX + DBL_EPSILON) {
rettv->vval.v_number = -VARNUMBER_MAX;
} else if (f > VARNUMBER_MAX) {
} else if (f >= VARNUMBER_MAX - DBL_EPSILON) {
rettv->vval.v_number = VARNUMBER_MAX;
} else {
rettv->vval.v_number = (varnumber_T)f;