oversky wrote:
> :echo eval('1/2')
> 0
As Danny mentioned, that is not strange as Vim follows the same
concepts as used in the C language (and others) where "1" is an
integer, but "1.0" (both without quotes) is a floating point
number.
You get the same in Python 2.7, where 1/2 also evaluates as 0.
You don't need "eval":
:echo 1.0/2
gives
0.5
If you have numbers as strings in variables, you could convert
them to floats like this:
:let n = "1"
:let d = "2"
:echo str2float(n)/str2float(d)
which gives 0.5.
John
--
You received this message from the "vim_use" 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