<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>lazy_skunk</author_name>
  <author_url>https://blog.hatena.ne.jp/lazy_skunk/</author_url>
  <blog_title>ちんぱんの雑記</blog_title>
  <blog_url>https://lazy-skunk.hatenablog.com/</blog_url>
  <categories>
  </categories>
  <description>ビット演算を知らないと言っても過言ではないくらい忘れていた。あれは実質知らなかったな…。 LeetCode で、整数の十進表記の桁数が偶数かどうかを判定するとき、最初は文字列に変換して数えていた。 def has_even_digit_count(num: int) -&gt; bool: return len(str(abs(num))) % 2 == 0 この例では、符号を桁数に含めないように abs を使っている。数値のまま桁を数え、その桁数の偶奇をビット演算で判定する方法もあった。 def has_even_digit_count(num: int) -&gt; bool: num = abs(n…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Flazy-skunk.hatenablog.com%2Fentry%2F2024%2F04%2F22%2F220848&quot; title=&quot;ビット演算の基本 - ちんぱんの雑記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2024-04-22 22:08:48</published>
  <title>ビット演算の基本</title>
  <type>rich</type>
  <url>https://lazy-skunk.hatenablog.com/entry/2024/04/22/220848</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
