Last active
June 19, 2023 02:25
-
-
Save ryochin/804c0c8f22f8de277566a9034733301e to your computer and use it in GitHub Desktop.
Elixir: 与えられた数値の指定されたビットの値を読み出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Bitwise | |
@doc """ | |
与えられた数値の指定されたビットの値を読み出す | |
### Example | |
``` | |
iex> bit_at(42, 3) | |
true | |
``` | |
""" | |
@spec bit_at(non_neg_integer, non_neg_integer) :: boolean | |
def bit_at(uint8, at) when (uint8 &&& 1 <<< at) == 0, do: false | |
def bit_at(_, _), do: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment