Class: Exonum::Float32T

Inherits:
Object
  • Object
show all
Defined in:
lib/exonum/types/primitive.rb

Class Method Summary collapse

Class Method Details

.fixed?Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/exonum/types/primitive.rb', line 163

def self.fixed?
  true
end

.serialize(value, buffer, from, shift = 0) ⇒ Object



167
168
169
170
171
172
173
# File 'lib/exonum/types/primitive.rb', line 167

def self.serialize value, buffer, from, shift=0
  value = (value * FLOAT_PRECISION_MULTIPLIER).round / FLOAT_PRECISION_MULTIPLIER
  [value].pack('e').bytes.each do |byte|
    buffer[from] = byte
    from += 1
  end
end

.sizeObject



159
160
161
# File 'lib/exonum/types/primitive.rb', line 159

def self.size
  4
end