Hi, 

2017-5-7(Sun) 22:42:50 UTC+9 h_east:
> Hi Bram and list,
> 
> I found a bug of float2nr()
> 
> How to reproduce:
> 
> Start vanilla Vim.
> 
> $ vim -Nu NONE
> Input the following command and checking result.
> 
> :echo float2nr(pow(2, 62))
> 4611686018427387904             <-- Expected
> 
> :echo float2nr(pow(2, 63))
> -9223372036854775808            <-- Unexpected!! Should be 9223372036854775807
> 
> :echo float2nr(pow(2, 64))
> 9223372036854775807             <-- Expected
> 
> :echo float2nr(-pow(2, 62))
> -4611686018427387904            <-- Expected
> 
> :echo float2nr(-pow(2, 63))
> -9223372036854775808            <-- Unexpected!! Should be 
> -9223372036854775807
> 
> :echo float2nr(-pow(2, 64))
> -9223372036854775807            <-- Expected
> 
> 
> I wrote a patch and add a test.
> 
> (I converted test65 to a new style test and added it to test_float_func.vim 
> and test_vimscript.vim)
> 
> NOTE:
> 
> This may be a bit related to Issue below. However, this is a bug of float2nr 
> () alone and needs to be fixed.
> 
> Define behavior for over/underflow in vim script arithmetic
> 
> https://groups.google.com/d/topic/vim_dev/_tqf8eQy5eA/discussion
> 
> Check it out.
> 
> BTW...
> 
> Perhaps, it is better to describe the effective range to :help Number.
> 
> In the case of 64 bit, -9223372036854775807 to 9223372036854775807 ?
> 
> -9223372036854775808 is a special number? (0 / 0 = -0x80000000 (like NaN for 
> Float) in :help expr-/ )

I'm going to correct the above remarks.

- Range of Number is -9223372036854775808 to 9223372036854775807, right?
- Range of `float2nr()` return value is -9223372036854775807 to 
9223372036854775807. 
  and special value `Nan` is -9223372036854775808. (From :help float2nr())
- Range of `str2nr()` return value is -9223372036854775807 to 
9223372036854775807. (Undocumented!!)

--
Best regards,
Hirohito Higashi (h_east)

> 
> --
> 
> Best regards,
> 
> Hirohito Higashi (h_east)
> 
> 
> 
> You can view, comment on, or merge this pull request online at:
> 
>   https://github.com/vim/vim/pull/1688
> 
> Commit Summary
> 
>   Fix float2nr() behavior
> 
> 
> File Changes
> 
>   
>     M
>     src/Makefile
>     (2)
>   
>   
>     M
>     src/evalfunc.c
>     (4)
>   
>   
>     M
>     src/testdir/Make_all.mak
>     (1)
>   
>   
>     M
>     src/testdir/Make_vms.mms
>     (2)
>   
>   
>     D
>     src/testdir/test65.in
>     (95)
>   
>   
>     D
>     src/testdir/test65.ok
>     (73)
>   
>   
>     M
>     src/testdir/test_float_func.vim
>     (47)
>   
>   
>     M
>     src/testdir/test_vimscript.vim
>     (43)
>   
> 
> 
> Patch Links:
> 
>   https://github.com/vim/vim/pull/1688.patch
>   https://github.com/vim/vim/pull/1688.diff
> 
> 
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui