Class: Integer

Inherits:
Object show all
Defined in:
lib/rlang/parser/ext/integer.rb

Instance Method Summary collapse

Instance Method Details

#to_little_endian(byte_count) ⇒ Object

Works for both signed and unsignd 32 or 64 bits integers



3
4
5
6
# File 'lib/rlang/parser/ext/integer.rb', line 3

def to_little_endian(byte_count)
  i = (self < 0) ? 2**(byte_count*8) + self : self
  ("%0#{byte_count*2}X" % i).scan(/../).reverse.map {|byte| "\\#{byte}"}.join('')
end