<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>rubytips86</author_name>
  <author_url>https://blog.hatena.ne.jp/rubytips86/</author_url>
  <blog_title>Ruby Tips!</blog_title>
  <blog_url>https://rubytips86.hatenablog.com/</blog_url>
  <categories>
  </categories>
  <description>数値を2進数で整形して表示するには、Kernel.#printにフォーマット%bを渡すと良い。以下は数値の下位1バイトを2進数で整形して表示する例である。 printf(&quot;%08b\n&quot;, 1986 &amp; 0b11111111) #=&gt; 11000010 フォーマット%08bは数値を2進数で8桁で0パディングして整形するという意味である。また下位1バイトを表示するため0b11111111と&amp;を取っている。もし整形して表示するのではなく、文字列を得たいのであれば、Kernel.#sprintfを利用すると良い。以下は数値を2進数で整形した文字列を得る例である。 p sprintf(&quot;%08b&quot;, …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Frubytips86.hatenablog.com%2Fentry%2F2014%2F03%2F29%2F092910&quot; title=&quot;数値を2進数で整形して表示する - Ruby Tips!&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>2014-03-29 09:29:10</published>
  <title>数値を2進数で整形して表示する</title>
  <type>rich</type>
  <url>https://rubytips86.hatenablog.com/entry/2014/03/29/092910</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
