Class: LibSL::LLS64
Instance Attribute Summary
Attributes inherited from LLNumber
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from LLNumber
endianness, #initialize
Class Method Details
.decode(data) ⇒ Object
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
# File 'lib/types.rb', line 267
def self.decode(data)
s64, data = LLNumber.decode(data, 'q1a*', LLS64)
if self.endianness == :big
s64.value = s64.value >> 56 |
(s64.value & 0xff000000000000) >> 40 |
(s64.value & 0xff0000000000) >> 24 |
(s64.value & 0xff00000000) >> 8 |
(s64.value & 0xff000000) << 8 |
(s64.value & 0xff0000) << 24 |
(s64.value & 0xff00) << 40 |
(s64.value & 0xff) << 56
end
return s64, data
end
|
Instance Method Details
#encode ⇒ Object
283
284
285
286
287
288
289
290
|
# File 'lib/types.rb', line 283
def encode()
raise ArgumentError, "Value out of range: #{@value}" if @value < -0x8000000000000000 or @value > 0x7fffffffffffffff
data = super('q')
if LLNumber::endianness == :big
data = data.unpack('C8').reverse.pack('C8')
end
return data
end
|