<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>licheng</author_name>
  <author_url>https://blog.hatena.ne.jp/licheng/</author_url>
  <blog_title>滴了庵日録</blog_title>
  <blog_url>https://lipoyang.hatenablog.com/</blog_url>
  <categories>
    <anon>プログラミング</anon>
  </categories>
  <description>C言語のfloat型のバイナリ表現形式に着目すると、2^x と log2(x) の近似値を高速に計算できます。 float型のバイナリ表現形式 float型は32ビットで、仮数部が23ビット(ケチ表現)、指数部が8ビット、MSBが符号ビットです。⇒ 単精度浮動小数点数 - Wikipediaこのように上位ビットが指数を表してることを利用します。 2^xの計算 実質、足し算1回で計算できます。 (ここでは検証のために浮動小数点⇒固定小数点の換算をしています。) // y = 2^x (x=-10～10) for (float x = -10.0; x &lt;= 10.0; x += 0.25) { …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Flipoyang.hatenablog.com%2Fentry%2F2021%2F02%2F03%2F202242&quot; title=&quot;2^x と log2(x) の高速な近似計算 - 滴了庵日録&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>https://cdn-ak.f.st-hatena.com/images/fotolife/l/licheng/20210203/20210203200620.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-02-03 20:22:42</published>
  <title>2^x と log2(x) の高速な近似計算</title>
  <type>rich</type>
  <url>https://lipoyang.hatenablog.com/entry/2021/02/03/202242</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
