Sha256: ec610ff0d8941837ed14b72af519ec2646a1b018f01c0987a816454a2558137f
Contents?: true
Size: 1.75 KB
Versions: 14
Compression:
Stored size: 1.75 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>pack (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 89</span> 89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pack</span> <span class="ruby-identifier">aPackedWidth</span> 90: <span class="ruby-identifier">bits</span> = <span class="ruby-identifier">length</span> 91: <span class="ruby-identifier">bits</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> <span class="ruby-comment cmt"># positive integers also have a sign bit (zero)</span> 92: 93: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">aPackedWidth</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">bits</span> 94: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"packed width #{aPackedWidth} must be at least #{bits} for integer #{self}"</span> 95: <span class="ruby-keyword kw">end</span> 96: 97: <span class="ruby-identifier">extend_sign</span>(<span class="ruby-identifier">bits</span>, <span class="ruby-identifier">aPackedWidth</span>) 98: <span class="ruby-keyword kw">end</span></pre> </body> </html>
Version data entries
14 entries across 14 versions & 1 rubygems