Skip to content

Instantly share code, notes, and snippets.

@kronos
Created April 6, 2010 22:29
Show Gist options
  • Select an option

  • Save kronos/358205 to your computer and use it in GitHub Desktop.

Select an option

Save kronos/358205 to your computer and use it in GitHub Desktop.
static VALUE
fix_lshift(val, width)
long val;
unsigned long width;
{
if (width > (sizeof(VALUE)*CHAR_BIT-1)
|| ((unsigned long)val)>>(sizeof(VALUE)*CHAR_BIT-1-width) > 0) {
return rb_big_lshift(rb_int2big(val), ULONG2NUM(width));
}
val = val << width;
return LONG2NUM(val);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment