Wednesday, February 6, 2019

Re: hexa numbers operations : masking, shifting

Le mercredi 6 février 2019 03:04:19 UTC+1, John Little a écrit :
> On Monday, February 4, 2019 at 11:47:50 PM UTC+13, niva...@gmail.com wrote:
>
> I'm sorry, I meant to type "a power of 2" in my answer, but my fingers didn't obey.
>
> > Shifting can be made multiplying or dividing by pow(x,2).
>
> (Assuming you meant pow(2,x).)
>
> You'd want to be very careful with that, pow() returns a Float and the result will become a Float, which is not valid in a lot of vim script contexts, including the bit functions. Float-ness can propagate unexpectedly in vim script. I'd use a literal number if the shift is constant, f.ex. "x / 16" for "x >> 4". If a variable shift is called for maybe use float2nr(pow(2, x)).
>
> Regards, John Little

Yes it's done. Thank you 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

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

No comments: