Class: LFSR::Fast::Size22

Inherits:
LFSR_Base
  • Object
show all
Defined in:
ext/lfsr/lfsr.c

Constant Summary collapse

MASK =
ULL2NUM(0x3fffffLLU)

Instance Method Summary collapse

Instance Method Details

#next_iObject



247
248
249
250
251
252
253
254
255
256
257
# File 'ext/lfsr/lfsr.c', line 247

VALUE rb_lfsr_next_i_22(VALUE self) {
  unsigned long long reg = NUM2ULL(ROBJECT(self)->as.ary[0]), max = NUM2ULL(ROBJECT(self)->as.ary[1]);

  label_shift22:
  reg = (reg >> 1) | ((bit(0)^bit(3)^bit(4)^bit(5)) << 0x15);
  if (reg > max) goto label_shift22;

  ROBJECT(self)->as.ary[0] = ULL2NUM(reg);

  return ULL2NUM(reg - 1);
}