Problem in bignorm

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

bignum.ce$B$Ne(Bbignorm()e$B$NCf$G!"e(B

if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {

e$B$H$7$F$$$kH=DjJ8$,$"$j$^$9$,!"$3$3$GK\Ev$K8+$J$$$H$$$1$J$$$Ne(B
e$B$O!"!Ve(BlenSIZEOF_BDIGITSe$B$,e(BVALUEe$B$K<}$^$k$+$I$&$+!W$G$O$J$/$F!"e(B
e$B!Ve(Blen
SIZEOF_BDIGITSe$B$,e(Blonge$B$K<}$^$k$+$I$&$+!W$J$N$G$O$J$$$+$He(B
e$B;W$$$^$9$,!"$I$&$G$7$g$&$+!#e(B

Index: bignum.c

RCS file: /home/cvs/ruby/bignum.c,v
retrieving revision 1.131
diff -u -1 -p -r1.131 bignum.c
— bignum.c 3 Jul 2006 20:07:09 -0000 1.131
+++ bignum.c 10 Jul 2006 22:22:00 -0000
@@ -104,3 +104,3 @@ bignorm(VALUE x)

  • if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
  • if (len*SIZEOF_BDIGITS <= sizeof(long)) {
    long num = 0;

e$B$b$C$H?<$/F’$9~$`$H!"$=$b$=$b$3$l$b!Ve(BVALUEe$B$He(Blonge$B$,F1$8%5%$%:!We(B
e$B$H0EL[$N$&$A$K2>Dj$7$Fe(BFixnume$B$+e(BBignume$B$+$NI_5o$r$re(Blong(e$B$h$je(B1bit
e$B>.$5$$CMe(B)e$B$G7h$a$F$7$^$C$F$$$k$N$,LdBj$J$o$1$G!“e(Blonge$B$h$je(BVALUE
e$B$,Bg$-$$>l9g$K$Oe(BFixnume$B$NHO0O$r$=$3$^$G3HBg$9$Y$-$G$”$k!"$H;We(B
e$B$&$N$G$9$,!"[email protected]$7$?$i?<$
$K$O$^$C$?$N$G!"8+$J$+$C$?$3$H$Ke(B
e$B$7$^$9e(B ^^;

e$B$=$l$G$O!#e(B

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

In message “Re: [ruby-dev:29013] problem in bignorm”
on Tue, 11 Jul 2006 07:26:15 +0900, “U.Nakamura”
[email protected] writes:

|bignum.ce$B$Ne(Bbignorm()e$B$NCf$G!"e(B
|
| if (lenSIZEOF_BDIGITS <= sizeof(VALUE)) {
|
|e$B$H$7$F$$$kH=DjJ8$,$"$j$^$9$,!"$3$3$GK\Ev$K8+$J$$$H$$$1$J$$$Ne(B
|e$B$O!"!Ve(Blen
SIZEOF_BDIGITSe$B$,e(BVALUEe$B$K<}$^$k$+$I$&$+!W$G$O$J$/$F!“e(B
|e$B!Ve(Blen*SIZEOF_BDIGITSe$B$,e(Blonge$B$K<}$^$k$+$I$&$+!W$J$N$G$O$J$$$+$He(B
|e$B;W$$$^$9$,!”$I$&$G$7$g$&$+!#e(B

e$B$$$d!"$3$l$O7k2L$,e(BFIXNUMe$B$K$J$k$+$I$&$+$,CN$j$?$$$o$1$G$9$+$i!"e(B
sizeof(long)e$B$G$O$J$/e(Bsizeof(VALUE)e$B$G$O$J$$$+$H!#e(B

e$BLdBj$,$"$k$H$9$k$He(Bsizeof(VALUE) > sizeof(long)e$B$N>l9g$,$"$C$?e(B
e$B$H$9$k$He(B(e$B$"$k$o$1$G$9$,e(B)e$B!"$=$l$re(Blonge$B$KG<$a$h$&$H$7$F$$$k$3$He(B
e$B$G$9$M!#e(B

long num = 0;

e$B$re(B

VALUE num = 0;

e$B$K$9$l$P$h$$$N$+$J$"!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:29018] Re: problem in bignorm”
on Jul.11,2006 13:49:28, [email protected] wrote:
| e$B$^$"!"@h$N%a!<%k$K$b=q$$$?$h$&$Ke(BFIXNUMe$B$,e(BVALUEe$B$K4X78$J$/Bg$-$5e(B
| e$B$,7h$^$C$F$k$3$H<+BN$,%J%K$G%=%l$G$9$1$Ie(B…

e$B$H$+=q$$$F$k4V$K$=$3$r2r>[email protected]$,F~$j$^$7$?$Me(B…

e$B%Q%C$H8+$?$H$3$m!"$?$V$s!":#F~$C$?$N$K2C$($F!“e(Bruby.he$B$He(Bnumeric.c
e$B$Ne(B
#if SIZEOF_INT < SIZEOF_LONG
e$B$be(B
#if SIZEOF_INT < SIZEOF_VOIDP
e$B$KJQ$($J$$$H$$$1$J$+$m$&!”$H$+!“e(Bnumeric.ce$B$K$^[email protected](Blonge$B7h$aBG$A$Je(B
e$BItJ,$,$1$C$3$&$”$k$H$$$&[email protected]$K5$IU$$$?$j$b$7$^$7$?$,!"$=$NJU$be(B
e$B4^$a$F!“8e$GLdBj$N4D6-$N$”$k$H$3$m$KLa$C$?$i$^$H$a$F3NG’$7$^e(B
e$B$9!#e(B

e$B$=$l$G$O!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:29016] Re: problem in bignorm”
on Jul.11,2006 13:29:44, [email protected] wrote:
| e$B$$$d!"$3$l$O7k2L$,e(BFIXNUMe$B$K$J$k$+$I$&$+$,CN$j$?$$$o$1$G$9$+$i!"e(B
| sizeof(long)e$B$G$O$J$/e(Bsizeof(VALUE)e$B$G$O$J$$$+$H!#e(B

ruby.he$B$Ke(B

#define FIXNUM_MAX (LONG_MAX>>1)

e$B$H=q$$$F$"$k$N$G$9$+$i!“e(BFIXNUMe$B$,e(BVALUEe$B$K4X78$J$/e(Blonge$B$K0MB8$7$?e(B
e$BBg$-$5$NCM$G$”[email protected]$i$+$J$N$G$O$J$$$+$H;W$C$?$j$9$k$N$Ge(B
e$B$9$,!"$=$3$+$i9M$($k$J$i$d$C$Q$je(Bsizeof(long)e$B$,0UL#E*[email protected]$7e(B
e$B$$$H;W$&$N$G$9$,!"$$$+$,$J$b$s$G$7$g$&$+!#e(B

e$B$^$"!"@h$N%a!<%k$K$b=q$$$?$h$&$Ke(BFIXNUMe$B$,e(BVALUEe$B$K4X78$J$/Bg$-$5e(B
e$B$,7h$^$C$F$k$3$H<+BN$,%J%K$G%=%l$G$9$1$Ie(B…

| e$BLdBj$,$"$k$H$9$k$He(Bsizeof(VALUE) > sizeof(long)e$B$N>l9g$,$"$C$?e(B
| e$B$H$9$k$He(B(e$B$"$k$o$1$G$9$,e(B)e$B!"$=$l$re(Blonge$B$KG<$a$h$&$H$7$F$$$k$3$He(B
| e$B$G$9$M!#e(B
|
| long num = 0;
|
| e$B$re(B
|
| VALUE num = 0;
|
| e$B$K$9$l$P$h$$$N$+$J$"!#e(B

e$BId9f$NLdBj$r$I$&$K$+$9$l$P!"$=$l$G$b$h$5$=$&$J5$$O$7$^$9!#e(B
e$B$H$9$k$H!"e(B

#if SIZEOF_LONG == SIZEOF_VOIDP
long num = 0;
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
LONG_LONG num = 0;
#else

error VALUEe$B$Oe(Bunsigned longe$B$+e(Bunsigned

LONG_LONGe$B$N$O$:e(B!
#endif

e$B$H$+$G$7$g$&$+!#$3$3$Ge(B#ife$B$O$+$C$3$o$k$$$J!#e(B

e$B$=$l$G$O!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B
e$B%5%V%8%’%/%HJQ$($^$7$?!#e(B

In message “[ruby-dev:29019] Re: problem in bignorm”
on Jul.11,2006 14:19:11, [email protected] wrote:
| | e$B$^$"!"@h$N%a!<%k$K$b=q$$$?$h$&$Ke(BFIXNUMe$B$,e(BVALUEe$B$K4X78$J$/Bg$-$5e(B
| | e$B$,7h$^$C$F$k$3$H<+BN$,%J%K$G%=%l$G$9$1$Ie(B…
|
| e$B$H$+=q$$$F$k4V$K$=$3$r2r>[email protected]$,F~$j$^$7$?$Me(B…

e$B$=$N8e$b$5$i$KJQ99$,F~$C$?$N$r:#:"8+$^$7$?!#e(B

[email protected]}$9$k$H!"8=;[email protected]$G$NJQ99FbMF$O!"e(B

(1) e$B?7$7$/e(BSIGNED_VALUEe$B$H$$$&7?e(B(e$B%^%/%me(B)e$B$,$G$-$?!#e(B
e$B$=$NL>$NDL$j!“e(BVALUEe$B$HF1$8Bg$-$5$GId9f$N$”$k7?$r0UL#$9$k!#e(B
(2) e$B?7$7$/e(BSIZEOF_VALUEe$B$H$$$&%^%/%m$,$G$-$?!#e(B
e$B$=$NL>$NDL$j!“e(BVALUE(e$B$He(BSIGNED_VALUE)e$B$NBg$-$5$r0UL#$9$k!#e(B
(3)
Fixnume$B$O!”=>Mh$N!Ve(Blonge$B$+$ie(B1bite$B>[email protected]?tCM!W$G$O$J$/$J$j!"e(B
e$B!Ve(BSIGNED_VALUEe$B$+$ie(B1bite$B>[email protected]?tCM!W$K$J$C$?!#e(B
(4) NUM2LONG(v)e$B!"e(BNUM2ULONG(v)e$B$O$=$l$>$le(Blonge$B!"e(Bungsigned
longe$B$Ge(B
e$B$O$J$/!"e(BSIGNED_VALUEe$B!"e(BVALUEe$B$rJV$9$h$&$K$J$C$?!#e(B

e$B$H$$$&$3$H$+$H;W$$$^$9!#e(B

e$B$G$9$,!"e(B(3)e$B$*$h$Se(B(4)e$B$+$i9M$($k$K!"e(B

(5)
FIX2LONG(v)e$B!"e(BFIX2ULONG(v)e$B$b$=$l$>$le(BSIGNED_VALUEe$B!"e(BVALUEe$B$re(B
e$BJV$9e(B

e$B$h$&[email protected]$H;W$&$N$G$9$,!"$^[email protected]$J$C$F$$$^$;$s!#e(B

e$B:#$^$G=q$+$l$?%3!<%I$Oe(B(e$B30It$N3HD%%i%$%V%i%j$b4^$a$Fe(B)FIX2LONGe$B!“e(B
NUM2LONGe$B$,e(Blonge$B$rJV$9$3$H$r4|[email protected]$m$&$H;W$$$^$9!#e(B
(4)e$B$He(B(5)e$B$r:NMQ$9$k$N$O$+$J$j%$%s%Q%/%H$N$”$k;[email protected]$H;W$&e(B
e$B$N$G$9$,!"K\Ev$K$3$NJ}8~$G?J$_$^$9$+e(B?
IL32LLP64e$B$J4D6-$J$s$F$[$H$s$I$J$$$s$G$9$+$i!"[email protected]$r0];}$7$Fe(B
Fixnume$B$Oe(Blong-1bite$B$H$$$&$3$H$K$7$F$*$/$N$b<j$N$h$&$J5$$b$7$^$9!#e(B

e$B$=$l$G$O!#e(B

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

In message “Re: [ruby-dev:29024] Fixnum on IL32LLP64 (was Re: problem in
bignorm)”
on Thu, 13 Jul 2006 00:18:42 +0900, “U.Nakamura”
[email protected] writes:

|[email protected]}$9$k$H!"8=;[email protected]$G$NJQ99FbMF$O!"e(B
|
|(1) e$B?7$7$/e(BSIGNED_VALUEe$B$H$$$&7?e(B(e$B%^%/%me(B)e$B$,$G$-$?!#e(B
| e$B$=$NL>$NDL$j!“e(BVALUEe$B$HF1$8Bg$-$5$GId9f$N$”$k7?$r0UL#$9$k!#e(B
|(2) e$B?7$7$/e(BSIZEOF_VALUEe$B$H$$$&%^%/%m$,$G$-$?!#e(B
| e$B$=$NL>$NDL$j!“e(BVALUE(e$B$He(BSIGNED_VALUE)e$B$NBg$-$5$r0UL#$9$k!#e(B
|(3) Fixnume$B$O!”=>Mh$N!Ve(Blonge$B$+$ie(B1bite$B>[email protected]?tCM!W$G$O$J$/$J$j!"e(B
| e$B!Ve(BSIGNED_VALUEe$B$+$ie(B1bite$B>[email protected]?tCM!W$K$J$C$?!#e(B
|(4) NUM2LONG(v)e$B!"e(BNUM2ULONG(v)e$B$O$=$l$>$le(Blonge$B!"e(Bungsigned longe$B$Ge(B
| e$B$O$J$/!"e(BSIGNED_VALUEe$B!"e(BVALUEe$B$rJV$9$h$&$K$J$C$?!#e(B
|
|e$B$H$$$&$3$H$+$H;W$$$^$9!#e(B

e$B$=$&$G$9$M!#e(B

|e$B$G$9$,!"e(B(3)e$B$*$h$Se(B(4)e$B$+$i9M$($k$K!"e(B
|
|(5) FIX2LONG(v)e$B!"e(BFIX2ULONG(v)e$B$b$=$l$>$le(BSIGNED_VALUEe$B!“e(BVALUEe$B$re(B
| e$BJV$9e(B
|
|e$B$h$&[email protected]$H;W$&$N$G$9$,!”$^[email protected]$J$C$F$$$^$;$s!#e(B

e$B3N$+$K!#8e$G$d$C$F$*$-$^$9!#e(B

|e$B:#$^$G=q$+$l$?%3!<%I$Oe(B(e$B30It$N3HD%%i%$%V%i%j$b4^$a$Fe(B)FIX2LONGe$B!“e(B
|NUM2LONGe$B$,e(Blonge$B$rJV$9$3$H$r4|[email protected]$m$&$H;W$$$^$9!#e(B
|(4)e$B$He(B(5)e$B$r:NMQ$9$k$N$O$+$J$j%$%s%Q%/%H$N$”$k;[email protected]$H;W$&e(B
|e$B$N$G$9$,!"K\Ev$K$3$NJ}8~$G?J$_$^$9$+e(B?
|IL32LLP64e$B$J4D6-$J$s$F$[$H$s$I$J$$$s$G$9$+$i!"[email protected]$r0];}$7$Fe(B
|Fixnume$B$Oe(Blong-1bite$B$H$$$&$3$H$K$7$F$*$/$N$b<j$N$h$&$J5$$b$7$^$9!#e(B

e$B$3$l$i$NJQ99$Oe(B1.9e$B8~$1$G$9$+$i!#e(B1.8e$B$Oe(B(1.8.5e$B$Oe(B)e$B$b$&$A$g$C$H$*e(B
[email protected]$d$+$JJQ99$K$9$k$D$b$j$G$9!#e(B

In article [email protected],
Yukihiro M. [email protected] writes:

|(4) NUM2LONG(v)e$B!"e(BNUM2ULONG(v)e$B$O$=$l$>$le(Blonge$B!"e(Bungsigned longe$B$Ge(B
| e$B$O$J$/!"e(BSIGNED_VALUEe$B!"e(BVALUEe$B$rJV$9$h$&$K$J$C$?!#e(B
|
|e$B$H$$$&$3$H$+$H;W$$$^$9!#e(B

e$B$=$&$G$9$M!#e(B

long e$B$8$c$J$$$b$N$r07$&$J$i!"e(BNUM2LONG, NUM2ULONG e$B$H$$$&L>A0e(B
e$B$OITE,@[email protected]$H;W$$$^$9!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

e$B4V$,6u$$$A$c$$$^$7$?$,B3$-$G$9!#e(B

e$BM%@hEY$NHf3SE*Dc$$OCBj$J$s$8$c$J$$$+$H;d$O;W$C$F$^$9$N$G!"e(B

1.8.5e$B$H$+!“M%@hEY$N9b$$OC$,$”$l$P$3$C$A$O8e2s$7$G$h$5$2!#e(B

In message “[ruby-dev:29025] Re: Fixnum on IL32LLP64 (was Re: problem in
bignorm)”
on Jul.13,2006 00:40:15, [email protected] wrote:
| |(5) FIX2LONG(v)e$B!"e(BFIX2ULONG(v)e$B$b$=$l$>$le(BSIGNED_VALUEe$B!“e(BVALUEe$B$re(B
| | e$BJV$9e(B
| |
| |e$B$h$&[email protected]$H;W$&$N$G$9$,!”$^[email protected]$J$C$F$$$^$;$s!#e(B
|
| e$B3N$+$K!#8e$G$d$C$F$*$-$^$9!#e(B

e$B$3$l$G!"e(B2 ** 32 == 0 e$B$Oe(B true e$B$8$c$J$/$J$j$^$7$?!#e(B
e$B$,!"e(Bp 2 ** 32 e$B$O0MA3$H$7$Fe(B 0 e$B$H=PNO$5$l$^$9!#e(B

e$B$J$s$G$+$H$$$&$H!“e(Brb_fix2str()e$B$NCf$Ge(BFIX2LONGe$B$N7k2L$re(Blonge$B$G<ue(B
e$B$1$F$k$N$,860x$G!”$3$l$O3:[email protected]@$re(BSIGNED_VALUEe$B$KJQ$($le(B
e$B$P$9$0$K2r7h$7$^$9!#e(B

e$B$H!"$$$&$h$&$J46$8$G!“e(BFIX2LONGe$B!“e(BFIX2ULONGe$B$re(Blonge$B$J$je(Bunsigned
long
e$B$J$j$G<u$1$F$k$H$3$m$O$^[email protected]$^[email protected]$$$C$Q$$$”$C$F!”$*$=$i$/$=$NB?e(B
e$B$/$GBP1~$,I,MW$G$9!#e(B
e$B$^$?!“e(Bsprintf()e$B7O$Ne(B “%ld”
e$B$H$$$&%U%)!<%^%C%H$KBP$7$Fe(BFIX2LONG
e$B$N7k2L$rEO$7$F$$$k$H$3$m$b$”$C$?$j$9$k$N$G$9$,!"$3$&$$$&$H$3e(B
e$B$m$Oe(B “%lld” e$B$K$7$J$1$l$P$$$1$J$+$C$?$j$9$k5$$,$7$^$9!#e(B

[email protected]$OD9$$$G$9!#e(B
e$BJL$K$=$ND9$$:n6H$rA4It$^$D$b$H$5$s$K$d$l$H$$$&5$$O$J$/$F!“J}e(B
e$B8~$,$3$l$G$$$$$J$i!”$b$A$m$s;d$,:n6H$7$^$9!#e(B

| e$B$3$l$i$NJQ99$Oe(B1.9e$B8~$1$G$9$+$i!#e(B1.8e$B$Oe(B(1.8.5e$B$Oe(B)e$B$b$&$A$g$C$H$*e(B
| [email protected]$d$+$JJQ99$K$9$k$D$b$j$G$9!#e(B

e$B$H$$$&$3$H$O!"e(B1.8e$B$b$J$s$i$+$NBP1~$r$7$^$9$+e(B?
e$B<B$Oe(B1.8e$B$r$$$8$k$3$H$OA4A39MN8$7$F$^$;$s$G$7$?!#e(B

e$B$=$l$G$O!#e(B

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

In message “Re: [ruby-dev:29042] Re: Fixnum on IL32LLP64 (was Re:
problem in bignorm)”
on Tue, 18 Jul 2006 01:40:09 +0900, “U.Nakamura”
[email protected] writes:

|# 1.8.5e$B$H$+!“M%@hEY$N9b$$OC$,$”$l$P$3$C$A$O8e2s$7$G$h$5$2!#e(B
|
|In message “[ruby-dev:29025] Re: Fixnum on IL32LLP64 (was Re: problem in bignorm)”
| on Jul.13,2006 00:40:15, [email protected] wrote:
|| |(5) FIX2LONG(v)e$B!"e(BFIX2ULONG(v)e$B$b$=$l$>$le(BSIGNED_VALUEe$B!“e(BVALUEe$B$re(B
|| | e$BJV$9e(B
|| |
|| |e$B$h$&[email protected]$H;W$&$N$G$9$,!”$^[email protected]$J$C$F$$$^$;$s!#e(B
||
|| e$B3N$+$K!#8e$G$d$C$F$*$-$^$9!#e(B
|
|e$B$3$l$G!"e(B2 ** 32 == 0 e$B$Oe(B true e$B$8$c$J$/$J$j$^$7$?!#e(B
|e$B$,!"e(Bp 2 ** 32 e$B$O0MA3$H$7$Fe(B 0 e$B$H=PNO$5$l$^$9!#e(B
|
|e$B$J$s$G$+$H$$$&$H!“e(Brb_fix2str()e$B$NCf$Ge(BFIX2LONGe$B$N7k2L$re(Blonge$B$G<ue(B
|e$B$1$F$k$N$,860x$G!”$3$l$O3:[email protected]@$re(BSIGNED_VALUEe$B$KJQ$($le(B
|e$B$P$9$0$K2r7h$7$^$9!#e(B

e$B$&!<$`!"$d$O$j<B5!$,$J$$$HFq$7$$$b$N$G$9$M!#e(B

|e$B$H!"$$$&$h$&$J46$8$G!“e(BFIX2LONGe$B!“e(BFIX2ULONGe$B$re(Blonge$B$J$je(Bunsigned long
|e$B$J$j$G<u$1$F$k$H$3$m$O$^[email protected]$^[email protected]$$$C$Q$$$”$C$F!”$*$=$i$/$=$NB?e(B
|e$B$/$GBP1~$,I,MW$G$9!#e(B
|e$B$^$?!“e(Bsprintf()e$B7O$Ne(B “%ld” e$B$H$$$&%U%)!<%^%C%H$KBP$7$Fe(BFIX2LONG
|e$B$N7k2L$rEO$7$F$$$k$H$3$m$b$”$C$?$j$9$k$N$G$9$,!"$3$&$$$&$H$3e(B
|e$B$m$Oe(B “%lld” e$B$K$7$J$1$l$P$$$1$J$+$C$?$j$9$k5$$,$7$^$9!#e(B
|
|[email protected]$OD9$$$G$9!#e(B
|e$BJL$K$=$ND9$$:n6H$rA4It$^$D$b$H$5$s$K$d$l$H$$$&5$$O$J$/$F!“J}e(B
|e$B8~$,$3$l$G$$$$$J$i!”$b$A$m$s;d$,:n6H$7$^$9!#e(B

e$B$A$g$C$HBT$C$F$/[email protected]$5$$$M!#e(B

FIX2INTe$B$Oe(Binte$B$rJV$9e(B(sizeof(int)<sizeof(VALUE)e$B$N$H$-!"%!<e(B
e$B%P!<%U%m!<%A%’%C%/IU$-e(B)
*
FIX2LONGe$B$Oe(Blonge$B$rJV$9e(B(sizeof(long)<sizeof(VALUE)e$B$N$H$-!"e(B
e$B%
!<%P!<%U%m!<%A%’%C%/IU$-e(B)
*
FIX2xxxe$B$Oe(Bvoid*e$B$HF1$8%5%$%:[email protected]?te(B(e$BId9fIU$-e(B)e$B$rJV$9e(B
*
FIX2Uyyye$B$Oe(Byyye$B$HF1$8%5%$%:[email protected]?te(B(e$BId9f$J$7e(B)e$B$rJV$9e(B

  • e$B!Ve(Bxxxe$B!W$r$I$s$JL>A0$K$9$k$+$OMW8!F$e(B

e$B$H$$$&$3$H$K$9$l$P!">/$J$/$H$be(BFIX2LONGe$B$K$h$ke(B"%ld"e$BLdBj$O$J$/e(B
e$B$J$j$^$9$M!#[email protected]!“e(BFIX2xxxe$B$H$+$re(Bprintfe$B$G=PNO$9$kJ}K!$,%”!<%-e(B
e$B%F%/%A%c$K$h$C$F!“e(B”%ld"[email protected]$C$?$j!“e(B”%lld"[email protected]$C$?$j$9$k$N$O$&$le(B
e$B$7$/$J$$$3$H$G$9$M$(!#e(B

e$B0lJ}!“e(BFixnume$B$r$=$N%”!<%-%F%/%A%c$Ne(Blonge$B$NHO0OFb$K8BDj$9$l$P!"e(B

  • FIX2xxxe$B$OITMWe(B(e$BL>A0$r9M$($J$/$F$h$$$N$O$&$l$7$$e(B)
  • e$B>o$Ke(Blonge$B$J$N$Ge(B"%ld"e$B$G%]!<%?%V%k$K=PNO$G$-$ke(B
  • VALUEe$B$GI=8=$G$-$kCM$9$Y$F$,I=8=$G$-$:$b$C$?$$$J$$e(B

e$B$H$$$&$3$H$K$J$j$^$9!#$I$C$A$,$$$$$+$J$"!#8D?ME*$K$O!V$b$C$?e(B
e$B$$$J$$!W$H$$$&;W$$$+$iA0<T$rA*Br$7$?$$$1$I!"[email protected]$bB?$$$G$9$Me(B
e$B$(!#e(B

|| e$B$3$l$i$NJQ99$Oe(B1.9e$B8~$1$G$9$+$i!#e(B1.8e$B$Oe(B(1.8.5e$B$Oe(B)e$B$b$&$A$g$C$H$*e(B
|| [email protected]$d$+$JJQ99$K$9$k$D$b$j$G$9!#e(B
|
|e$B$H$$$&$3$H$O!"e(B1.8e$B$b$J$s$i$+$NBP1~$r$7$^$9$+e(B?
|e$B<B$Oe(B1.8e$B$r$$$8$k$3$H$OA4A39MN8$7$F$^$;$s$G$7$?!#e(B

1.8e$B$re(BIL32LLP64e$B$GF0$+$7$?$$$C$FOC$O$J$+$C$?$s$G$7$?$C$1!#e(B
st_data_te$B$re(BVALUEe$B$HF1$8%5%$%:$K$9$k$H$+!"$=$NJU$r0U<1$7$F$N$3e(B
e$B$H$G$7$?$1$I!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:29054] Re: Fixnum on IL32LLP64 (was Re: problem in
bignorm)”
on Jul.18,2006 16:28:48, [email protected] wrote:
| e$B$&!<$`!"$d$O$j<B5!$,$J$$$HFq$7$$$b$N$G$9$M!#e(B

e$B$h!<$7$^$D$b$H$5$s$K<B5!$r%W%l%<%s%H$7$Fe(BWindowse$B;H$$$K$J$C$F$be(B
e$B$i$&$>!<e(B
e$B$H$$$&$[$I$*6b$J$$$N$,;DG0!#e(B

| e$B$A$g$C$HBT$C$F$/[email protected]$5$$$M!#e(B
|
| * VALUEe$B$Oe(Bvoide$B$HF1$8%5%$%:[email protected]?te(B
|
| * FIX2INTe$B$Oe(Binte$B$rJV$9e(B(sizeof(int)<sizeof(VALUE)e$B$N$H$-!"%
!<e(B
| e$B%P!<%U%m!<%A%’%C%/IU$-e(B)
| * FIX2LONGe$B$Oe(Blonge$B$rJV$9e(B(sizeof(long)<sizeof(VALUE)e$B$N$H$-!“e(B
| e$B%!<%P!<%U%m!<%A%’%C%/IU$-e(B)
| * FIX2xxxe$B$Oe(Bvoid
e$B$HF1$8%5%$%:[email protected]?te(B(e$BId9fIU$-e(B)e$B$rJV$9e(B
| * FIX2Uyyye$B$Oe(Byyye$B$HF1$8%5%$%:[email protected]?te(B(e$BId9f$J$7e(B)e$B$rJV$9e(B
|
| * e$B!Ve(Bxxxe$B!W$r$I$s$JL>A0$K$9$k$+$OMW8!F$e(B
|
| e$B$H$$$&$3$H$K$9$l$P!”>/$J$/$H$be(BFIX2LONGe$B$K$h$ke(B"%ld"e$BLdBj$O$J$/e(B
| e$B$J$j$^$9$M!#[email protected]!“e(BFIX2xxxe$B$H$+$re(Bprintfe$B$G=PNO$9$kJ}K!$,%”!<%-e(B
| e$B%F%/%A%c$K$h$C$F!“e(B”%ld"[email protected]$C$?$j!“e(B”%lld"[email protected]$C$?$j$9$k$N$O$&$le(B
| e$B$7$/$J$$$3$H$G$9$M$(!#e(B

e$BL>A0$H$7$F$O!"e(B
VINTe$B!"e(BVUINT
SVINTe$B!“e(BUVINT
INTPTRe$B!“e(BUINTPTR
e$B$J$I$H$$$&%”%$%G%”$,K?e(BIRCe$B%A%c%s%M%k$G$O=P$F$$$^$7$?!#e(BFYIe$B!#e(B

| e$B0lJ}!“e(BFixnume$B$r$=$N%”!<%-%F%/%A%c$Ne(Blonge$B$NHO0OFb$K8BDj$9$l$P!“e(B
|
| * FIX2xxxe$B$OITMWe(B(e$BL>A0$r9M$($J$/$F$h$$$N$O$&$l$7$$e(B)
| * e$B>o$Ke(Blonge$B$J$N$Ge(B”%ld"e$B$G%]!<%?%V%k$K=PNO$G$-$ke(B
| * VALUEe$B$GI=8=$G$-$kCM$9$Y$F$,I=8=$G$-$:$b$C$?$$$J$$e(B
|
| e$B$H$$$&$3$H$K$J$j$^$9!#$I$C$A$,$$$$$+$J$"!#8D?ME*$K$O!V$b$C$?e(B
| e$B$$$J$$!W$H$$$&;W$$$+$iA0<T$rA*Br$7$?$$$1$I!"[email protected]$bB?$$$G$9$Me(B
| e$B$(!#e(B

e$B$b$C$?$$$J$$$s$G$9$1$I!“8=<BLdBj$H$7$F!“Aa$/e(BBignume$B$K$J$C$A$ce(B
e$B$&[email protected]=Dc2<$d$J$s$+$H!“[email protected]$1$N6lO+$rHf3Se(B
e$B$9$k$H!”$I$&$b6lO+$K8+9g$C$F$J$$$s$8$c$J$+$m$&$+!”$H$$$&$N$,!“e(B
e$BA0$K;n$7$K:n6H$7$F$_$?$H$-$N;d$N46A[$G$7$?!#e(B
e$B$=$N$H$-$Oe(BNUM2LONGe$B$”$?$j$r$$$8$C$F$?$”$?$j$G$b$&Ej$2=P$7$^$7e(B
e$B$?$1$Ie(B(e$BG&BQNO$,$J$$e(B

| || e$B$3$l$i$NJQ99$Oe(B1.9e$B8~$1$G$9$+$i!#e(B1.8e$B$Oe(B(1.8.5e$B$Oe(B)e$B$b$&$A$g$C$H$*e(B
| || [email protected]$d$+$JJQ99$K$9$k$D$b$j$G$9!#e(B
| |
| |e$B$H$$$&$3$H$O!“e(B1.8e$B$b$J$s$i$+$NBP1~$r$7$^$9$+e(B?
| |e$B<B$Oe(B1.8e$B$r$$$8$k$3$H$OA4A39MN8$7$F$^$;$s$G$7$?!#e(B
|
| 1.8e$B$re(BIL32LLP64e$B$GF0$+$7$?$$$C$FOC$O$J$+$C$?$s$G$7$?$C$1!#e(B
| st_data_te$B$re(BVALUEe$B$HF1$8%5%$%:$K$9$k$H$+!”$=$NJU$r0U<1$7$F$N$3e(B
| e$B$H$G$7$?$1$I!#e(B

e$B;d$N$[$&$O!"$J$s$H$J$/$N8D?ME*M_5ae(B(We$BGU$GLk99$+$7$7$F;n9g3+;Oe(B
e$B$rBT$C$F$k4V$N2K$D$V$7e(B)e$B$+$i;[email protected][email protected]$C$?$N$G!“e(B1.8e$B$^$G:n6He(B
e$B$9$k$3$H$O$”$s$^$j9M$($F$^$;$s$G$7$?!#e(B
rubye$BK\BNB&$NBP1~$,:[email protected]$G!"%W%i%C%H%U%)!<%`8GM-$NLdBj$b$^e(B
[email protected]$^[email protected];[email protected]$7$F$^$9$7!#e(B

e$B$H$3$m$G!“e(BWin64e$B0J30$Ke(BIL32LLP64e$B$J%W%i%C%H%U%)!<%$C$F<B:_$7$Fe(B e$B$k$N$G$7$g$&$+!#e(B e$B$0$0$k$H!"$J$s$+e(BAlphae$B$N%W%i%C%H%U%)!<%$G$=$s$J$s$,$”$C$?$h$&e(B
e$B$J$J$+$C$?$h$&$JOC$,;68+$5$l$k$N$G$9$,!"$h$/$o$+$i$:!#e(B

e$B$=$l$G$O!#e(B

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

In message “Re: [ruby-dev:29055] Re: Fixnum on IL32LLP64 (was Re:
problem in bignorm)”
on Tue, 18 Jul 2006 16:51:50 +0900, “U.Nakamura”
[email protected] writes:

|e$B$b$C$?$$$J$$$s$G$9$1$I!“8=<BLdBj$H$7$F!“Aa$/e(BBignume$B$K$J$C$A$ce(B
|e$B$&[email protected]=Dc2<$d$J$s$+$H!“[email protected]$1$N6lO+$rHf3Se(B
|e$B$9$k$H!”$I$&$b6lO+$K8+9g$C$F$J$$$s$8$c$J$+$m$&$+!”$H$$$&$N$,!“e(B
|e$BA0$K;n$7$K:n6H$7$F$_$?$H$-$N;d$N46A[$G$7$?!#e(B
|e$B$=$N$H$-$Oe(BNUM2LONGe$B$”$?$j$r$$$8$C$F$?$”$?$j$G$b$&Ej$2=P$7$^$7e(B
|e$B$?$1$Ie(B(e$BG&BQNO$,$J$$e(B

e$B$&!<$s!"$8$c$"!"e(BFixnum=longe$B$GBE6($7$A$c$*$&$+$J$"e(B(e$B:,@-$J$7e(B)e$B!#e(B

|| 1.8e$B$re(BIL32LLP64e$B$GF0$+$7$?$$$C$FOC$O$J$+$C$?$s$G$7$?$C$1!#e(B
|| st_data_te$B$re(BVALUEe$B$HF1$8%5%$%:$K$9$k$H$+!"$=$NJU$r0U<1$7$F$N$3e(B
|| e$B$H$G$7$?$1$I!#e(B
|
|e$B;d$N$[$&$O!"$J$s$H$J$/$N8D?ME*M_5ae(B(We$BGU$GLk99$+$7$7$F;n9g3+;Oe(B
|e$B$rBT$C$F$k4V$N2K$D$V$7e(B)e$B$+$i;[email protected][email protected]$C$?$N$G!“e(B1.8e$B$^$G:n6He(B
|e$B$9$k$3$H$O$”$s$^$j9M$($F$^$;$s$G$7$?!#e(B
|rubye$BK\BNB&$NBP1~$,:[email protected]$G!"%W%i%C%H%U%)!<%`8GM-$NLdBj$b$^e(B
|[email protected]$^[email protected];[email protected]$7$F$^$9$7!#e(B

e$B$=$&$+!#$8$c$"!"e(B1.8e$B$K$D$$$F$O$J$K$b$7$J$$$H!#e(B

|e$B$H$3$m$G!“e(BWin64e$B0J30$Ke(BIL32LLP64e$B$J%W%i%C%H%U%)!<%$C$F<B:_$7$Fe(B |e$B$k$N$G$7$g$&$+!#e(B |e$B$0$0$k$H!"$J$s$+e(BAlphae$B$N%W%i%C%H%U%)!<%$G$=$s$J$s$,$”$C$?$h$&e(B
|e$B$J$J$+$C$?$h$&$JOC$,;68+$5$l$k$N$G$9$,!"$h$/$o$+$i$:!#e(B

e$BA0$K$$$8$C$?$H$-$N$*$$m$2$J5-21$K$h$l$P!"e(Blinux on alphae$B$Oe(B
[email protected]$C$?$h$&$J5$$,$7$^$9!#e(B

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

In mail “[ruby-dev:29055] Re: Fixnum on IL32LLP64 (was Re: problem in
bignorm)”
“U.Nakamura” [email protected] wrote:

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

e$B$H$3$m$G!“e(BWin64e$B0J30$Ke(BIL32LLP64e$B$J%W%i%C%H%U%)!<%$C$F<B:_$7$Fe(B e$B$k$N$G$7$g$&$+!#e(B e$B$0$0$k$H!"$J$s$+e(BAlphae$B$N%W%i%C%H%U%)!<%$G$=$s$J$s$,$”$C$?$h$&e(B
e$B$J$J$+$C$?$h$&$JOC$,;68+$5$l$k$N$G$9$,!"$h$/$o$+$i$:!#e(B

Alpha [email protected]$H!“e(BWindows e$B0J30$Ge(B
LLP64e$B$C$FOC$OCN$j$^$;$s!#>/$J$/$H$be(B
Linux/Alpha, NetBSD/Alpha, FreeBSD/Alpha, Tru64UNIX e$B$Oe(B
e$B%U%D!<$Ke(B LP64 e$B$G$9!#e(BOpenBSD/Alpha
e$B$O7P83$J$$$G$9$,!”$^$"e(B LP64
e$B$G$7$g$&!#$0$0$C$F$b$=$l$i$7$$>pJs$7$+=P$^$;$s$7!#e(B

[email protected]$,$"$k$H$9$l$Pe(B OpenVMS [email protected]$H;W$$$^$9$,!"e(BVMS
e$B$O;H$C$?$3$H$,e(B
e$B$J$$$N$G$h$/$o$+$j$^$;$s!#[email protected](B
http://h50146.www5.hp.com/products/software/oe/openvms/manual/v82/pdfs/jvms_082_porting.pdf
e$B$Ne(B 17 e$B%Z!<%8$K$h$k$He(B

OpenVMS e$B$O!";HMQ$5$l$F$$$k%G!<%?!&%b%G%k$K4X$7$F0U?^E*$Ke(B
e$B$"$$$^$$$K$J$C$F$$$^$9!#B?$/$N%W%m%0%i%$Oe(B ILP32 e$B%b%G%k$Ge(B e$B$"$k$+$N$h$&$K%3%s%Q%$%k$5$l$^$9$,!"%7%9%F%$NBgItJ,$Oe(B P64
e$B$^$?$Oe(B LP64 e$B%b%G%k$r;HMQ$7$F$$$k$+$N$h$&$KF0:n$7$^$9!#@0?te(B
e$B$NId9f3HD%5,B’$O!"$3$N%G!<%?!&%b%G%k$NF)[email protected]$r8~>e$^$?$Oe(B
e$BDc2<$5$;$k$N$K=EMW$JLr3d$r2L$?$7$^$9!#e(BItanium
e$B%"!<%-%F%/%A%ce(B
e$B$N5,B’$G$O=c?h$Je(B LP64 e$B%G!<%?!&%b%G%k$,Dj5A$5$l$F$$$^$9$,!"e(B
OpenVMS I64 e$B$G$O>[email protected]$r0];}$7$F$$$^$9!#e(B

[email protected]$=$&$G$9!#!D!D7k6I$h$/$o$+$i$J$$$N$G!"e(BVMS
e$B$OB>$N$+$?$KG$$;$^$9!#e(B

e$B$=$NB>$Ne(B Alpha e$B>e$Ne(B OS e$B$K4X$7$F$O!"$=$b$=$be(B Ruby
e$B$r%3%s%Q%$%ke(B
e$B$7$??M$,B8:_$9$k$N$+$o$+$i$J$$$N$GL5;k$7$F$h$$$s$8$c$J$$$G$7$g$&$+!#e(B

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

In message “Re: [ruby-dev:31058] Re: Fixnum on IL32LLP64 (was Re:
problem in bignorm)”
on Tue, 26 Jun 2007 13:27:11 +0900, “U.Nakamura”
[email protected] writes:

|| e$B$&!<$s!"$8$c$"!"e(BFixnum=longe$B$GBE6($7$A$c$*$&$+$J$"e(B(e$B:,@-$J$7e(B)e$B!#e(B
|
|e$B$H$$$&$o$1$G!“e(BIL32LLP64e$B4D6-$G$Oe(BFixnume$B$re(Blonge$B$NHO0O$H$9$k!”$H$$e(B
|e$B$&[email protected]$,=P$F$$$k$H$$$&$3$H$G$$$$$G$7$g$&$+e(B?
|e$B$3$l$G$h$1$l$P!“0J2<$N%Q%C%A$re(Bcommite$B$7$?$$$N$G$9$,!”$$$$$G$9e(B
|e$B$+$Me(B?

e$B$O$$!#$h$m$7$/!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

e$B$$$-$J$je(B1e$BG/6a$/A0$NOC$G62=L$J$s$G$9$,!"e(B

In message “[ruby-dev:29056] Re: Fixnum on IL32LLP64 (was Re: problem in
bignorm)”
on Jul.18,2006 17:04:07, [email protected] wrote:
| |e$B$b$C$?$$$J$$$s$G$9$1$I!“8=<BLdBj$H$7$F!“Aa$/e(BBignume$B$K$J$C$A$ce(B
| |e$B$&[email protected]=Dc2<$d$J$s$+$H!“[email protected]$1$N6lO+$rHf3Se(B
| |e$B$9$k$H!”$I$&$b6lO+$K8+9g$C$F$J$$$s$8$c$J$+$m$&$+!”$H$$$&$N$,!“e(B
| |e$BA0$K;n$7$K:n6H$7$F$_$?$H$-$N;d$N46A[$G$7$?!#e(B
| |e$B$=$N$H$-$Oe(BNUM2LONGe$B$”$?$j$r$$$8$C$F$?$”$?$j$G$b$&Ej$2=P$7$^$7e(B
| |e$B$?$1$Ie(B(e$BG&BQNO$,$J$$e(B
|
| e$B$&!<$s!"$8$c$"!"e(BFixnum=longe$B$GBE6($7$A$c$*$&$+$J$"e(B(e$B:,@-$J$7e(B)e$B!#e(B

e$B$H$$$&$o$1$G!“e(BIL32LLP64e$B4D6-$G$Oe(BFixnume$B$re(Blonge$B$NHO0O$H$9$k!”$H$$e(B
e$B$&[email protected]$,=P$F$$$k$H$$$&$3$H$G$$$$$G$7$g$&$+e(B?
e$B$3$l$G$h$1$l$P!“0J2<$N%Q%C%A$re(Bcommite$B$7$?$$$N$G$9$,!”$$$$$G$9e(B
e$B$+$Me(B?

e$BB>$K$be(Binsns.defe$B$X$N%Q%C%A$,I,MW$J$s$G$9$,!"[email protected](B

e$B$5$s$HAjCL$7$^$9!#e(B

Index: include/ruby/ruby.h

— include/ruby/ruby.h (revision 12615)
+++ include/ruby/ruby.h (working copy)
@@ -151,13 +151,8 @@

endif

#endif

-#ifdef LONG_LONG_VALUE
-# define FIXNUM_MAX (LLONG_MAX>>1)
-# define FIXNUM_MIN RSHIFT((LONG_LONG)LLONG_MIN,1)
-#else
-# define FIXNUM_MAX (LONG_MAX>>1)
-# define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
-#endif
+#define FIXNUM_MAX (LONG_MAX>>1)
+#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)

#define FIXNUM_FLAG 0x01
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
Index: bignum.c

— bignum.c (revision 12615)
+++ bignum.c (working copy)
@@ -107,8 +107,8 @@
long len = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);

  • if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
  • SIGNED_VALUE num = 0;
  • if (len*SIZEOF_BDIGITS <= sizeof(long)) {
  • long num = 0;
    while (len–) {
    num = BIGUP(num) + ds[len];
    }
    @@ -415,7 +415,7 @@
    }
    len *= strlen(str)*sizeof(char);
  • if (len <= (sizeof(VALUE)*CHAR_BIT)) {
  • if (len <= (sizeof(long)*CHAR_BIT)) {
    unsigned long val = strtoul(str, &end, base);

if (str < end && *end == ‘_’) goto bigparse;

e$B$=$l$G$O!#e(B

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

| Privacy Policy | Terms of Service | Remote Ruby Jobs