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_
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/multiarray/int.rb', line 244 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 |