Module: Hornetseye::INT_::Match
- Included in:
- Node
- Defined in:
- lib/multiarray/int.rb
Overview
Namespace containing method for matching elements of type INT_
Instance Method Summary collapse
-
#fit(*values) ⇒ Class
Method for matching elements of type INT_.
Instance Method Details
#fit(*values) ⇒ Class
Method for matching elements of type INT_
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/multiarray/int.rb', line 212 def fit( *values ) if values.all? { |value| value.is_a? Integer } bits = 8 ubits = 8 signed = false values.each do |value| bits *= 2 until ( -2**(bits-1) ... 2**(bits-1) ).include? value if value < 0 signed = true else ubits *= 2 until ( 0 ... 2**ubits ).include? value end end bits = signed ? bits : ubits if bits <= 64 Hornetseye::INT bits, signed else super *values end else super *values end end |