Yegappen wrote:

> > > The following bitwise functions are currently supported: and(), or(),
> > > xor() and invert().
> > > But there is no function or operator for bitwise left/right shift.
> > > Add the lshift() and rshift() functions for bitwise left shift and
> > > right shift.
> >
> > I'm wondering if it is worth it. You can also use "* 2" for left shift
> > and "/ 2" for right shift. It's not exactly the same (considering
> > overflow), but does that matter in a Vim script?
> >
> >
> >
> Without these functions, to left/right shift a number, you need to
> do something like the following:
> 
> Left Shift:
> let c = a * float2nr(pow(2, b))
> 
> Right Shift:
> let c = float2nr(floor(a / pow(2, b)))
> 
> I thought it would be simpler to have a separate function for this.

Hmm, what if we have an operator for integer pow()?
E.g. "**" could be used:  "2 ** b"
That would be useful in general.

-- 
Everyone has a photographic memory. Some don't have film.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202106261726.15QHQKuP385971%40masaka.moolenaar.net.

Raspunde prin e-mail lui