# Bignum \$B\$N%a%=%C%I\$+\$i\$N(B bigzero_p

e\$B%o%J%Y\$H?=\$7\$^\$9!#e(B

Ruby e\$B\$+\$ie(B Bignum e\$B%\$%s%9%?%s%9\$N%a%=%C%I\$,8F\$P\$l\$?>l9g\$K\$Oe(B
bigzero_p e\$B\$G\$9\$Y\$F\$N%S%C%H\$r8+\$kI,MW\$O\$"\$^\$jL5\$\$\$h\$&\$K;W\$\$\$^\$9!#e(B

e\$B\$=\$3\$G!"3N<B\$Ke(B Fixnum
e\$B\$NHO0O\$K\$J\$\$\$3\$H\$r<(\$9%U%i%0\$GJ,4t\$9\$k%Q%C%A\$r=q\$-\$^\$7\$?!#e(B
e\$B;n83E*\$Ke(B to_s e\$B\$,[email protected]\$1IU2C\$7\$F\$\$\$^\$9!#e(B

# Index: include/ruby/ruby.h

— include/ruby/ruby.h (revision 16344)
+++ include/ruby/ruby.h (working copy)
@@ -610,9 +610,11 @@
#define RBIGNUM_POSITIVE_P(b) RBIGNUM_SIGN(b)
#define RBIGNUM_NEGATIVE_P(b) (!RBIGNUM_SIGN(b))

# -#define RBIGNUM_EMBED_FLAG FL_USER2 -#define RBIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3) -#define RBIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+3) +#define RBIGNUM_UNFIXABLE_FLAG FL_USER2 + +#define RBIGNUM_EMBED_FLAG FL_USER3 +#define RBIGNUM_EMBED_LEN_MASK (FL_USER6|FL_USER5|FL_USER4) +#define RBIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+4)#define RBIGNUM_LEN(b) ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? (long)((RBASIC(b)->flags >> RBIGNUM_EMBED_LEN_SHIFT) & Index: bignum.c

— bignum.c (revision 16344)
+++ bignum.c (working copy)
@@ -44,6 +44,10 @@
bigzero_p(VALUE x)
{
long i;
+

• if (FL_TEST(x, RBIGNUM_UNFIXABLE_FLAG)) {

• return 0;

• }
for (i = 0; i < RBIGNUM_LEN(x); ++i) {
if (BDIGITS(x)[i]) return 0;
}
@@ -1000,6 +1004,7 @@
{
int base;

• FL_SET(x, RBIGNUM_UNFIXABLE_FLAG);
if (argc == 0) base = 10;
else {
VALUE b;

In article [email protected],
wanabe [email protected] writes:

Ruby e\$B\$+\$ie(B Bignum e\$B%\$%s%9%?%s%9\$N%a%=%C%I\$,8F\$P\$l\$?>l9g\$K\$Oe(B
bigzero_p e\$B\$G\$9\$Y\$F\$N%S%C%H\$r8+\$kI,MW\$O\$"\$^\$jL5\$\$\$h\$&\$K;W\$\$\$^\$9!#e(B

e\$B;W\$C\$?\$s\$G\$9\$,!":G>e0L%S%C%H\$+\$i8!::\$9\$k\$"\$?\$j\$G<j\$rBG\$D\$N\$Oe(B
e\$B\$I\$&\$G\$9\$+\$M!#e(B

e\$B\$^\$D\$b\$He(B e\$B\$f\$-\$R\$m\$G\$9e(B

In message “Re: [ruby-dev:34651] Re: Bignum e\$B\$N%a%=%C%I\$+\$i\$Ne(B
bigzero_p”
on Sun, 11 May 2008 23:44:49 +0900, Nobuyoshi N.
[email protected] writes:

|At Sun, 11 May 2008 15:55:26 +0900,
|Tanaka A. wrote in [ruby-dev:34649]:
|> > Ruby e\$B\$+\$ie(B Bignum e\$B%\$%s%9%?%s%9\$N%a%=%C%I\$,8F\$P\$l\$?>l9g\$K\$Oe(B
|> > bigzero_p e\$B\$G\$9\$Y\$F\$N%S%C%H\$r8+\$kI,MW\$O\$"\$^\$jL5\$\$\$h\$&\$K;W\$\$\$^\$9!#e(B
|>
|> e\$B;W\$C\$?\$s\$G\$9\$,!":G>e0L%S%C%H\$+\$i8!::\$9\$k\$"\$?\$j\$G<j\$rBG\$D\$N\$Oe(B
|> e\$B\$I\$&\$G\$9\$+\$M!#e(B
|
|e\$B\$[\$H\$s\$I\$N%1!<%9\$G\$Oe(BRBIGNUM_LENe\$B\$Oe(B0e\$B\$+e(B1e\$B!"\$^\$l\$J%1!<%9\$G\$be(B2e\$B;_\$^[email protected](B
|e\$B\$m\$&\$H;W\$C\$F\$\$\$?\$N\$G\$9\$,!"\$=\$s\$J\$KBg\$-\$Je(BBignum 0e\$B\$,BgNL\$K\$G\$-\$k%1!<e(B
|e\$B%9\$,\$"\$j\$^\$7\$?\$+!#e(B

e\$B\$h\$C\$]\$I\$N\$3\$H\$,\$J\$\$\$H:[email protected]\$m\$&\$H\$\$\$&\$3\$H\$G!"\$"\$^\$jI,e(B
[email protected]\$O46\$8\$^\$;\$s!#\$+\$J\$jBg\$-\$J?t\$G2<\$NJ}\$N%S%C%H\$,\$<\$s\$V%<%m\$Ce(B
e\$B\$F%1!<%[email protected]\$H\$A\$g\$C\$H\$O:9\$,=P\$k\$N\$+\$J!#\$G\$b!"\$=\$l\$J\$ie(Bakre\$B\$5\$se(B
e\$B\$N\$*\$C\$7\$c\$k\$h\$&\$K>e0L\$+\$i%A%’%C%/\$7\$F\$\$\$/\$N\$,\$h\$5\$=\$&\$G\$9\$M!#e(B

e\$B2>\$K85\$N%Q%C%A\$NJ}8~\$G9T\$/\$H\$9\$k\$H!"e(Bbigzero_pe\$B\$G??\$rJV\$9D>A0\$Ke(B
e\$B\$b%U%i%0\$r%;%C%H\$7\$?J}\$,\$h\$\$\$G\$7\$g\$&\$M!#e(B

[email protected]\$G\$9!#e(B

At Sun, 11 May 2008 15:55:26 +0900,
Tanaka A. wrote in [ruby-dev:34649]:

Ruby e\$B\$+\$ie(B Bignum e\$B%\$%s%9%?%s%9\$N%a%=%C%I\$,8F\$P\$l\$?>l9g\$K\$Oe(B
bigzero_p e\$B\$G\$9\$Y\$F\$N%S%C%H\$r8+\$kI,MW\$O\$"\$^\$jL5\$\$\$h\$&\$K;W\$\$\$^\$9!#e(B

e\$B;W\$C\$?\$s\$G\$9\$,!":G>e0L%S%C%H\$+\$i8!::\$9\$k\$"\$?\$j\$G<j\$rBG\$D\$N\$Oe(B
e\$B\$I\$&\$G\$9\$+\$M!#e(B

e\$B\$[\$H\$s\$I\$N%1!<%9\$G\$Oe(BRBIGNUM_LENe\$B\$Oe(B0e\$B\$+e(B1e\$B!"\$^\$l\$J%1!<%9\$G\$be(B2e\$B;_\$^[email protected](B
e\$B\$m\$&\$H;W\$C\$F\$\$\$?\$N\$G\$9\$,!"\$=\$s\$J\$KBg\$-\$Je(BBignum
0e\$B\$,BgNL\$K\$G\$-\$k%1!<e(B
e\$B%9\$,\$"\$j\$^\$7\$?\$+!#e(B

e\$B%o%J%Y\$G\$9!#e(B

2008/05/11 23:44 Nobuyoshi N. [email protected]:

At Sun, 11 May 2008 15:55:26 +0900,
Tanaka A. wrote in [ruby-dev:34649]:

e\$B;W\$C\$?\$s\$G\$9\$,!":G>e0L%S%C%H\$+\$i8!::\$9\$k\$"\$?\$j\$G<j\$rBG\$D\$N\$Oe(B
e\$B\$I\$&\$G\$9\$+\$M!#e(B

e\$B\$[\$H\$s\$I\$N%1!<%9\$G\$Oe(BRBIGNUM_LENe\$B\$Oe(B0e\$B\$+e(B1e\$B!"\$^\$l\$J%1!<%9\$G\$be(B2e\$B;_\$^[email protected](B
e\$B\$m\$&\$H;W\$C\$F\$\$\$?\$N\$G\$9\$,!"\$=\$s\$J\$KBg\$-\$Je(BBignum 0e\$B\$,BgNL\$K\$G\$-\$k%1!<e(B
e\$B%9\$,\$"\$j\$^\$7\$?\$+!#e(B

test/ruby/test_bignum.rb e\$B\$Ne(B test_too_big_to_s
e\$B\$N%%H%k%M%C%/\$rC5\$7\$?7k2Le(B
bigzero_p e\$B\$K9T\$-Ce\$-\$^\$7\$?!#e(B
e\$B\$G\$9\$,M>J,\$J%U%i%[email protected]_\$9\$k\$h\$je(B akr
e\$B\$5\$s\$N0F\$N\$[\$&\$,\$h\$C\$]\$I\$h\$5\$=\$&\$K;W\$\$\$^\$9!#e(B

e\$B\$^\$D\$b\$He(B e\$B\$f\$-\$R\$m\$G\$9e(B

In message “Re: [ruby-dev:34657] Re: Bignum e\$B\$N%a%=%C%I\$+\$i\$Ne(B
bigzero_p”
on Mon, 12 May 2008 19:44:59 +0900, wanabe [email protected]
writes:

|> e\$B\$[\$H\$s\$I\$N%1!<%9\$G\$Oe(BRBIGNUM_LENe\$B\$Oe(B0e\$B\$+e(B1e\$B!"\$^\$l\$J%1!<%9\$G\$be(B2e\$B;\$^[email protected](B
|> e\$B\$m\$&\$H;W\$C\$F\$\$\$?\$N\$G\$9\$,!"\$=\$s\$J\$KBg\$-\$Je(BBignum 0e\$B\$,BgNL\$K\$G\$-\$k%1!<e(B
|> e\$B%9\$,\$"\$j\$^\$7\$?\$+!#e(B
|
|test/ruby/test_bignum.rb e\$B\$Ne(B test_too_big_to_s e\$B\$N%%H%k%M%C%/\$rC5\$7\$?7k2Le(B
|bigzero_p e\$B\$K9T\$-Ce\$-\$^\$7\$?!#e(B
|e\$B\$G\$9\$,M>J,\$J%U%i%[email protected]
\$9\$k\$h\$je(B akr e\$B\$5\$s\$N0F\$N\$[\$&\$,\$h\$C\$]\$I\$h\$5\$=\$&\$K;W\$\$\$^\$9!#e(B

e\$B\$=\$&\$G\$7\$?\$+!#:#F|e(Bakre\$B\$5\$s\$,%3%_%C%H\$5\$l\$^\$7\$?\$N\$G\$=\$l\$K\$h\$je(B
e\$B%%H%k%M%C%/\$,\$I\$&\$J\$C\$?\$+4X?4\$,\$"\$j\$^\$9!#e(B

e\$B%o%J%Y\$G\$9!#e(B

2008/05/12 23:33 Yukihiro M. [email protected]:

|test/ruby/test_bignum.rb e\$B\$Ne(B test_too_big_to_s e\$B\$N%%H%k%M%C%/\$rC5\$7\$?7k2Le(B
|bigzero_p e\$B\$K9T\$-Ce\$-\$^\$7\$?!#e(B
|e\$B\$G\$9\$,M>J,\$J%U%i%[email protected]_\$9\$k\$h\$je(B akr e\$B\$5\$s\$N0F\$N\$[\$&\$,\$h\$C\$]\$I\$h\$5\$=\$&\$K;W\$\$\$^\$9!#e(B

e\$B\$=\$&\$G\$7\$?\$+!#:#F|e(Bakre\$B\$5\$s\$,%3%_%C%H\$5\$l\$^\$7\$?\$N\$G\$=\$l\$K\$h\$je(B
e\$B%%H%k%M%C%/\$,\$I\$&\$J\$C\$?\$+4X?4\$,\$"\$j\$^\$9!#e(B

to_s e\$B\$,8F\$S=P\$5\$l\$F\$+\$ie(B RangeError
e\$B\$^\$G?t==IC\$+\$+\$C\$F\$\$\$?\$H\$3\$m\$,e(B
e\$B0l=V\$G\$9\$`\$h\$&\$K\$J\$j\$^\$7\$?!#e(B
e\$B\$*[email protected]\$\$\$?3’\$5\$s!JFC\$Ke(B akr
e\$B\$5\$s!K\$"\$j\$,\$H\$&\$4\$6\$\$\$^\$7\$?!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.