Sha256: 0e5966ed38cdacf71206af9dbe3021e7bbaa563dedaf72c9ab84b876381d932d

Contents?: true

Size: 1.57 KB

Versions: 14

Compression:

Stored size: 1.57 KB

Contents

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>log2 (Integer)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre>    <span class="ruby-comment cmt"># File lib/ruby-vpi/integer.rb, line 24</span>
24:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log2</span>
25:     <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;integer must be positive&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
26:     <span class="ruby-identifier">bin</span> = <span class="ruby-identifier">to_s</span>(<span class="ruby-value">2</span>)
27: 
28:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bin</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^10+$/</span>
29:       <span class="ruby-identifier">bin</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
30:     <span class="ruby-keyword kw">else</span>
31:       <span class="ruby-identifier">bin</span>.<span class="ruby-identifier">length</span>
32:     <span class="ruby-keyword kw">end</span>
33:   <span class="ruby-keyword kw">end</span></pre>
</body>
</html>

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ruby-vpi-12.0.1 ref/ruby/classes/Integer.src/M000012.html
ruby-vpi-12.0.0 ref/ruby/classes/Integer.src/M000012.html
ruby-vpi-11.1.0 ref/ruby/classes/Integer.src/M000012.html
ruby-vpi-11.1.1 ref/ruby/classes/Integer.src/M000012.html
ruby-vpi-12.1.0 ref/ruby/classes/Integer.src/M000012.html
ruby-vpi-13.0.0 ref/ruby/classes/Integer.src/M000008.html
ruby-vpi-12.0.2 ref/ruby/classes/Integer.src/M000012.html
ruby-vpi-14.0.0 ref/ruby/classes/Integer.src/M000008.html
ruby-vpi-15.0.1 ref/ruby/classes/Integer.src/M000008.html
ruby-vpi-15.0.0 ref/ruby/classes/Integer.src/M000008.html
ruby-vpi-15.0.2 ref/ruby/classes/Integer.src/M000008.html
ruby-vpi-8.1.0 ref/ruby/classes/Integer.src/M000010.html
ruby-vpi-9.0.0 ref/ruby/classes/Integer.src/M000012.html
ruby-vpi-8.2.0 ref/ruby/classes/Integer.src/M000011.html