2013-04-03 03:34:31 -04:00
|
|
|
#include "ruby.h"
|
2014-02-14 10:29:10 -05:00
|
|
|
#include "internal.h"
|
2013-04-03 03:34:31 -04:00
|
|
|
|
|
|
|
static VALUE
|
|
|
|
bug_big_zero(VALUE self, VALUE length)
|
|
|
|
{
|
|
|
|
long len = NUM2ULONG(length);
|
|
|
|
VALUE z = rb_big_new(len, 1);
|
2014-02-15 16:17:34 -05:00
|
|
|
MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len);
|
2013-04-03 03:34:31 -04:00
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
2013-06-29 11:57:07 -04:00
|
|
|
static VALUE
|
|
|
|
bug_big_negzero(VALUE self, VALUE length)
|
|
|
|
{
|
|
|
|
long len = NUM2ULONG(length);
|
|
|
|
VALUE z = rb_big_new(len, 0);
|
2014-02-15 16:17:34 -05:00
|
|
|
MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len);
|
2013-06-29 11:57:07 -04:00
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
2013-04-03 03:34:31 -04:00
|
|
|
void
|
|
|
|
Init_bigzero(VALUE klass)
|
|
|
|
{
|
|
|
|
rb_define_singleton_method(klass, "zero", bug_big_zero, 1);
|
2013-06-29 11:57:07 -04:00
|
|
|
rb_define_singleton_method(klass, "negzero", bug_big_negzero, 1);
|
2013-04-03 03:34:31 -04:00
|
|
|
}
|