e$B0J2<$N$h$&$K!“e(BBignum e$B$Ne(B 0 e$B$r%S%C%H1i;;$NH]Dj$7$?$H$-$Ke(B
0 e$B$Ke(B
e$B$J$k$3$H$,$”$j$^$9!#e(B
% ./ruby -ve ’
big_neg = 0x40000000.coerce(-1)[0]
big_zero = 0x40000000.coerce(0)[0]
p big_zero % big_neg
p ~big_zero’
ruby 1.9.0 (2007-07-15 patchlevel 0) [i686-linux]
0
0
e$B$,!">e5-$+$ie(B p big_zero % big_neg e$B$r>J$/$H!"5sF0$,JQ$o$C$F$=e(B
e$B$&$O$J$i$J$/$J$j$^$9!#e(B
% ./ruby -ve ’
big_neg = 0x40000000.coerce(-1)[0]
big_zero = 0x40000000.coerce(0)[0]
#p big_zero % big_neg
p ~big_zero’
ruby 1.9.0 (2007-07-15 patchlevel 0) [i686-linux]
-1
e$B$J$+$@$G$9!#e(B
At Sun, 15 Jul 2007 09:47:44 +0900,
Tanaka A. wrote in [ruby-dev:31229]:
e$B0J2<$N$h$&$K!“e(BBignum e$B$Ne(B 0 e$B$r%S%C%H1i;;$NH]Dj$7$?$H$-$Ke(B 0 e$B$Ke(B
e$B$J$k$3$H$,$”$j$^$9!#e(B
e$B$,!">e5-$+$ie(B p big_zero % big_neg e$B$r>J$/$H!"5sF0$,JQ$o$C$F$=e(B
e$B$&$O$J$i$J$/$J$j$^$9!#e(B
Bignume$B$Ne(B0e$B$Oe(B(%e$B7PM3$Ge(B)bigtrunc()e$B$rDL$k$He(Blen=0e$B$K$J$k$s$G$9$,!"e(B
rb_big_neg()e$B$,e(Blen==0e$B$N>l9g$r9MN8$7$F$$$J$$$?$a$G$9$M!#e(B
bigtrunc()e$B$Ge(B0e$B$K$7$J$$$h$&$K$9$k$+!“e(Brb_big_neg()e$B$Ge(Blen==0e$B$N>l9g$re(B
e$B9MN8$9$k$+!”$I$C$A$,$$$$$G$7$g$&!#8e<T$@$1$@$H!"B>$G$b$A$c$s$He(B
e$B9MN8$7$F$$$k$+A4It%A%’%C%/$7$J$$$H$$$1$J$$$+$i!"KI1RE*$KN>J}$Ge(B
e$B$9$+$M$’!#e(B
Index: trunk/bignum.c
— trunk/bignum.c (revision 12794)
+++ trunk/bignum.c (working copy)
@@ -98,5 +98,5 @@ bigtrunc(VALUE x)
BDIGIT *ds = BDIGITS(x);
- while (len-- && !ds[len]);
- while (–len && !ds[len]);
RBIGNUM(x)->len = ++len;
return x;
@@ -1038,4 +1038,5 @@ rb_big_neg(VALUE x)
ds = BDIGITS(z);
i = RBIGNUM(x)->len;
- if (!i) return INT2FIX(~(SIGNED_VALUE)0);
while (i–) {
ds[i] = ~ds[i];
Index: stable/bignum.c
===================================================================
— stable/bignum.c (revision 12794)
+++ stable/bignum.c (working copy)
@@ -105,5 +105,5 @@ bigtrunc(x)
BDIGIT *ds = BDIGITS(x);
- while (len-- && !ds[len]);
- while (–len && !ds[len]);
RBIGNUM(x)->len = ++len;
return x;
@@ -1100,4 +1100,5 @@ rb_big_neg(x)
ds = BDIGITS(z);
i = RBIGNUM(x)->len;
- if (!i) return INT2FIX(~(SIGNED_VALUE)0);
while (i–) ds[i] = ~ds[i];
RBIGNUM(z)->sign = !RBIGNUM(z)->sign;
In article
[email protected],
Nobuyoshi N. [email protected] writes:
bigtrunc()e$B$Ge(B0e$B$K$7$J$$$h$&$K$9$k$+!“e(Brb_big_neg()e$B$Ge(Blen==0e$B$N>l9g$re(B
e$B9MN8$9$k$+!”$I$C$A$,$$$$$G$7$g$&!#8e<T$@$1$@$H!"B>$G$b$A$c$s$He(B
e$B9MN8$7$F$$$k$+A4It%A%‘%C%/$7$J$$$H$$$1$J$$$+$i!"KI1RE*$KN>J}$Ge(B
e$B$9$+$M$’!#e(B
e$B$=$&$G$9$M!#8e<T$@$1%Q%C%A$rEv$F$F!“e(Btest_integer.rb e$B$Ge(B VS
e$B$re(B
e$B$<$s$Ve(B Bignum e$B$K$7$F;n$9$H!”$^$@2x$7$$7k2L$,=P$F$-$^$9$+$i!#e(B