Hi Bram, On Mon, Nov 15, 2021 at 11:08 AM Bram Moolenaar <[email protected]> wrote:
> I appear to have missed this one. Bit shift does not apply to floats, your > example does not seem representative. > Left Shift: let c = a * float2nr(pow(2, b)) Right Shift: let c = float2nr(floor(a / pow(2, b))) The above examples are not doing bit shifts of a float. To compute 2 ^ n, you need to use the pow() function which returns a float. You then need to use float2nr() to remove the fraction. > lshift(val, 4) would be equivalent to "val * 16" and rshift(val, 4) > equivalent to "val / 16". > > > If you know the number of bits to shift beforehand, then you can use a hard coded number like 16. Otherwise, you need to use the pow() function to compute 2 ^ n. Regards, Yegappan -- -- 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/CAAW7x7ma_PnB4a%2B2xeT%3DZvpR-D8ydLycSFBMnrFvRbt78eZO0w%40mail.gmail.com.
