On Fri, Oct 21, 2022 at 05:52:09PM +1300, Aiden Langley wrote:
> Kia ora,
>
> I'm working with a shell script that does this:
>
> ```
> for i in $(seq 1 9)
> do
> tags=$((1 << ($i - 1)))
> ...
> end
> ```
shifting a positive number left by one bit is equivalent to multiplying it by 2
So you can use exponentiation:
set tags (math "2 ^ ($i - 1)")
>
> Source: https://github.com/riverwm/river/blob/master/example/init
>
> It's shifting the bits to produce a 32 character string that's used to tag
> windows for a window manager. The window manager view changes depending on
> windows & these 32 characters for each of them. They use the bitwise operator
> to perform binary magic that's beyond me honestly.
>
> Anyway, I'm wondering if there's an equivalent fish `math` function or
> operator to perform bitwise shifts.
>
> Ngā mihi,
> Aiden
>
> --
> *Aiden Langley*
> Kaipūkaha Rorohiko | Software Engineer
>
>
> _______________________________________________
> Fish-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fish-users
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users