# bitwise logical operators

2 messages
Open this post in threaded view
|

## bitwise logical operators

 bitwise logical operators Are there bitwise logical operators (and, or, xor) for vim? -- 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
Open this post in threaded view
|

## Re: bitwise logical operators

 Ответ на сообщение «bitwise logical operators», присланное в 19:06:30 17 сентября 2010, Пятница, отправитель Bee: I do not know any. When I needed bitwise logical operators, I had to write the following workaround (works only on non-negative integers): "{{{3 num.and function s:F.num.and(v1, v2)     let [v1, v2]=[a:v1, a:v2]     let list=[]     while v1 || v2         let [nv1, nv2]=[v1/2, v2/2]         call add(list, ((nv1*2!=v1)&&(nv2*2!=v2)))         let [v1, v2]=[nv1, nv2]     endwhile     let r=0     while !empty(list)         let r=(r*2) + remove(list, -1)     endwhile     return r endfunction "{{{3 num.or function s:F.num.or(v1, v2)     let [v1, v2]=[a:v1, a:v2]     let list=[]     while v1 || v2         let [nv1, nv2]=[v1/2, v2/2]         call add(list, ((nv1*2!=v1)||(nv2*2!=v2)))         let [v1, v2]=[nv1, nv2]     endwhile     let r=0     while !empty(list)         let r=(r*2) + remove(list, -1)     endwhile     return r endfunction (These functions are defined in my stuf.vim plugin, but you should not use it as the wrapper that allows using them outside of the plugin, uses a very slow argument checks). Текст сообщения: > bitwise logical operators > > Are there bitwise logical operators (and, or, xor) for vim? signature.asc (205 bytes) Download Attachment