From f43305edf5fd0357f6506c9498b98ce7f92959fe Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Mon, 29 Mar 2021 17:58:30 +0800 Subject: [PATCH] Update binary.md --- contents/algorithms/binary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/algorithms/binary.md b/contents/algorithms/binary.md index 81d71154..c11dd1f3 100644 --- a/contents/algorithms/binary.md +++ b/contents/algorithms/binary.md @@ -17,7 +17,7 @@ Some helpful utility snippets: - Set kth bit: `num |= (1 << k)`. - Turn off kth bit: `num &= ~(1 << k)`. - Toggle the kth bit: `num ^= (1 << k)`. -- To check if a number is a power of 2, `num & num - 1 == 0` or `num & (-num) == num`. +- To check if a number is a power of 2, `(num & num - 1) == 0` or `(num & (-num)) == num`. ## Corner cases