Class: Noyes::FloatSplitter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_impl/compression.rb

Overview

Splits a float into an array containint its sign bit, its exponent, and its significand

Instance Method Summary collapse

Instance Method Details

#<<(data) ⇒ Object


62
63
64
65
66
67
68
69
# File 'lib/ruby_impl/compression.rb', line 62

def << data
  data.pack('g*').unpack('N*').map do |bits|
    signbit = bits >> 31
    exponent = (bits & 0x7F800000) >> 23
    significand = bits & 0x007FFFFF
    [signbit, exponent - 127, significand]
end
end