Module: Integer::IntegerExtensions

Included in:
Integer
Defined in:
lib/ragweed/utils.rb

Instance Method Summary collapse

Instance Method Details

#ffsObject



145
146
147
148
149
150
151
152
# File 'lib/ragweed/utils.rb', line 145

def ffs
  i = 0
  v = self
  while((v >>= 1) != 0)
    i += 1
  end
  return i
end

#sx16Object



142
# File 'lib/ragweed/utils.rb', line 142

def sx16; ([self].pack "s").unpack("S").first; end

#sx32Object



143
# File 'lib/ragweed/utils.rb', line 143

def sx32; ([self].pack "l").unpack("L").first; end

#sx8Object

sign extend



141
# File 'lib/ragweed/utils.rb', line 141

def sx8; ([self].pack "c").unpack("C").first; end

#to_b16Object



137
# File 'lib/ragweed/utils.rb', line 137

def to_b16; [self].pack "n"; end

#to_b32Object



135
# File 'lib/ragweed/utils.rb', line 135

def to_b32; [self].pack "N"; end

#to_l16Object



136
# File 'lib/ragweed/utils.rb', line 136

def to_l16; [self].pack "v"; end

#to_l32Object

Convert integers to binary strings



134
# File 'lib/ragweed/utils.rb', line 134

def to_l32; [self].pack "L"; end

#to_u8Object



138
# File 'lib/ragweed/utils.rb', line 138

def to_u8; [self].pack "C"; end