[Feature #2968] mail protected]$rJV$9%a%=%C%I

Feature #2968: [email protected]$rJV$9%a%=%C%Ie(B
http://redmine.ruby-lang.org/issues/show/2968

e$B5/I<<Te(B: Yui NARUSE
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: core

[email protected]$rJV$9%a%=%C%I$,M_$7$$$G$9!#e(B
e$B<g$?$kA[DjMQES$Oe(B 0.0 e$B$He(B -0.0 e$B$r6hJL$7$?$$$H$-$G$9!#e(B
e$B$3$l$O!e(B0.0 > -0.0 e$B$de(B 0.0 == -0.0
e$B$G$OCN$k$3$H$,$G$-$^$;$s!#e(B
e$B$H$j$$($:e(B flo.to_s[0] == ?-
e$B$GCN$k$3$H$,$G$-$^$9$,!"$3$l$G$O$"$s$^$j$G$9!#e(B

e$BG:$_$I$3$m$O$$$D$b$NDL$j%a%=%C%IL>$G$9$,!"e(B

  • Numeric#positive? e$B$He(B Numeric#negative?
  • Numeric#sign -> e$BIi$Ge(B -1e$B!"@5$Ge(B 1
  • Numeric#sign? -> e$BIi$Ge(B true, [email protected]$Ge(B false (signbit(3)
    e$B$K=,$&e(B)
    e$B$"$?$j$G$7$g$&$+!#e(B

e$B$$$+$,$G$7$g$&!#e(B

e$BB<ED$G$9!#e(B

On 2010/03/16, at 3:38, Yui NARUSE wrote:

[email protected]$rJV$9%a%=%C%I$,M_$7$$$G$9!#e(B
e$B<g$?$kA[DjMQES$Oe(B 0.0 e$B$He(B -0.0 e$B$r6hJL$7$?$$$H$-$G$9!#e(B
e$B$3$l$O!e(B0.0 > -0.0 e$B$de(B 0.0 == -0.0 e$B$G$OCN$k$3$H$,$G$-$^$;$s!#e(B
e$B$H$j$$($:e(B flo.to_s[0] == ?- e$B$GCN$k$3$H$,$G$-$^$9$,!"$3$l$G$O$"$s$^$j$G$9!#e(B

e$BG:$_$I$3$m$O$$$D$b$NDL$j%a%=%C%IL>$G$9$,!"e(B

  • Numeric#positive? e$B$He(B Numeric#negative?
  • Numeric#sign -> e$BIi$Ge(B -1e$B!"@5$Ge(B 1
  • Numeric#sign? -> e$BIi$Ge(B true, [email protected]$Ge(B false (signbit(3) e$B$K=,$&e(B)
    e$B$"$?$j$G$7$g$&$+!#e(B

Numeric#sign? e$B$h$j$O!"e(BNumeric#positive? e$B$He(B Numeric#negative?
e$B$rDs6!$9$ke(B
e$BJ}$,;d$O9%$-$G$9!#e(B

Numeric#sign e$B$bF1;~$KDs6!$5$l$F$$$FNI$$$H;W$$$^$9!#e(B

e$B$H$3$m$G!"$3$l$i$N%a%=%C%I$Oe(B Complex
e$B$G$O$I$N$h$&$K?6Iq$&$s$G$7$g$&!)e(B

  • Numeric e$B$GDs6!$9$k%a%=%C%I$O<BIt$K$D$$$F$NId9f$r07$$!"e(B
    e$B5uIt$K$D$$$F$Oe(B Complex e$B$GF1N`$N%a%=%C%I$rDs6!$9$k!#e(B
  • Numeric e$B$GDs6!$9$k%a%=%C%I$re(B Complex e$B$+$i$Oe(B undef
    e$B$9$k!#e(B
    e$B<BIt$d5uIt$NId9f$,CN$j$?$$>l9g$Oe(B Complex#real.positive?
    e$B$N$h$&$K$9$k!#e(B
    e$B$3$Ne(B2e$B%Q%?!<%s$,;W$$$D$-$^$7$?!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: removed[email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

e$B%A%1%C%He(B #2968 e$B$,99?7$5$l$^$7$?!#e(B (by Shyouhei U.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BRejectede$B$KJQ99e(B

f > 0 or 1.0 / f > 0

[email protected]$a$J$s$G$9$+e(B?

http://redmine.ruby-lang.org/issues/show/2968

e$B%A%1%C%He(B #2968 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

e$B<B?t$N$_$NA[Dj$G$7$?$N$G!"e(BNumerice$B$G$O$J$/!"e(BInteger, Float,
Rational e$B8DJL$KDj5A$7$?J}$,NI$+$C$?$+$b$7$l$^$;$s!#e(B

f > 0 or 1.0 / f > 0 [email protected]$a$J$s$G$9$+e(B?
workaround e$B$H$7$F$O$=$A$i$NJ}$,$h$$$G$9$M!"$"$j$,$H$&$4$6$$$^$9!#e(B
e$B$7$+$7!"$3$NJ}K!$G$b$^[email protected]!"e(B1e$B%S%C%HFI$a$P$$$$$b$N$rL5BL$KJ#;($K$d$C$F$$$^$;$s$+!#e(B


http://redmine.ruby-lang.org/issues/show/2968

e$B$`$i$?$G$9!#e(B

On 2010/03/16, at 8:04, Shyouhei U. wrote:

f > 0 or 1.0 / f > 0

[email protected]$a$J$s$G$9$+e(B?

e$BA0<T$G$Oe(B -0.0 e$B$NId9f$rD4$Y$i$l$^$;$s!#e(B
e$B$+$H$$$C$F8e<T$h$j$Oe(B negative? e$B$H=q$+$l$F$$$kJ}$,e(B
e$BJ,$+$j$d$9$$5$$,$7$^$9!#e(B

e$B$b$&[email protected]$$K$J$k$3$H$O!e(B1.0 / -0.0 e$B$Ge(B -Infinity
e$B$,[email protected]$i$l$k;v$,e(B
e$B%!<%-%F%/%A%c$K0MB8$;$:7h$^$C$F$$$k$N$+$I$&$+$G$9!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

Yui NARUSE :

(f > 0 or 1.0 / f > 0)

double
d = -0.0
assert_equal(0, d)
assert_equal(-INFINITY, 1.0/d)

sign==strict

1.0/-0.0 VAX

1.0/-0.0-Inf-0.0

e$B%A%1%C%He(B #2968 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

(f > 0 or 1.0 / f > 0) e$B$H$$$&<q;]$+$H;W$$$^$9!#e(B

e$B$G!"$=$b$=$b$NF05!$Oe(B
[email protected]@.$9$k%a%=%C%I$N%F%9%H$r$9$k:]$K!e(B
d = -0.0
assert_equal(0, d)
assert_equal(-INFINITY, 1.0/d)
e$B$J$I$H=q$/$N$O>iD9$H$$$&$N$,$$j$^$7$?!#e(B

1.0/-0.0 e$B$Oe(B VAX [email protected]$H$I$&$J$s$G$7$g$&$M!#e(B

http://redmine.ruby-lang.org/issues/show/2968

e$B%A%1%C%He(B #2968 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

e$B$G!"$=$b$=$b$NF05!$Oe(B [email protected]@.$9$k%a%=%C%I$N%F%9%H$r$9$k:]$K!e(B
d = -0.0
assert_equal(0, d)
assert_equal(-INFINITY, 1.0/d)
e$B$J$I$H=q$/$N$O>iD9$H$$$&$N$,$$j$^$7$?!#e(B

e$B$=$l$Oe(Bsigne$B$,M_$7$$$s$8$c$J$/$Fe(B==e$B$h$j$be(Bstricte$B$JEyCMH=Dj$,M_$7$$$H$$$&OC$G$Oe(B

e$B$3$NNc$K4X$7$F$O$=$&$G$9$M!#e(B
Float#eql? e$B$Oe(B 0.0 e$B$He(B -0.0 e$B$r6hJL$9$k!"$H$+$G$b!#e(B

[email protected]=Dj$OM_$7$/$J$k$3$H$,$?$^$K$"$k$N$G$9$,!"$?$$$F$$$Oe(B n >=
0 e$B$G$h$$$N$G<gD%$H$7$F<e$/$O$J$j$^$9!#e(B
NaN e$B$NId9f$b%P%$%J%j$r8+$J$$$HH=Dj$G$-$J$$$1$I!";H$o$J$$$7$J$!e(B

http://redmine.ruby-lang.org/issues/show/2968

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

2010e$BG/e(B3e$B7ne(B16e$BF|e(B11:37 KOSAKI Motohiro
[email protected]n.invalid:

e$B>/$J$=$&$G$9!#e(B
e$BB?>/>iD9$J=q$-J}$K$J$C$F$$$F$b$+$^$o$J$$$N$G$O!)e(B

e$BMQES$H$7$F$O$H$j$"$($:%F%9%H%1!<%9$J$N$G$9$,!"GX7J$H$7$F$Oe(B Float
e$B$NIbF0>[email protected]?t$H$7$F$Ne(B
e$BFbIt9=B$$,1#JC$5$l$9$.$F$$$k$H$$$&[email protected]$rLdBj;k$7$F$$$^$9!#e(B
[email protected]$1$G$J$/!"e(BFloate$B$N2>?tIt$d;X?tIt$b$H$l$J$$$H$+!#e(B

e$B%A%1%C%He(B #2968 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

e$B<B?t$N$_$NA[Dj$G$7$?$N$G!"e(BNumerice$B$G$O$J$/!"e(BInteger, Float, Rational e$B8DJL$KDj5A$7$?J}$,NI$+$C$?$+$b$7$l$^$;$s!#e(B

f > 0 or 1.0 / f > 0 [email protected]$a$J$s$G$9$+e(B?
workaround e$B$H$7$F$O$=$A$i$NJ}$,$h$$$G$9$M!"$"$j$,$H$&$4$6$$$^$9!#e(B
e$B$7$+$7!"$3$NJ}K!$G$b$^[email protected]!"e(B1e$B%S%C%HFI$a$P$$$$$b$N$rL5BL$KJ#;($K$d$C$F$$$^$;$s$+!#e(B

e$BA[DjMQES$,AH9~$_%/%i%9$N%F%9%H%1!<%[email protected]$H$9$k$H!"$&$l$7$$?M$O$H$F$be(B
e$B>/$J$=$&$G$9!#e(B
e$BB?>/>iD9$J=q$-J}$K$J$C$F$$$F$b$+$^$o$J$$$N$G$O!)e(B

e$B$7$+$7!"$3$NJ}K!$G$b$^[email protected]!"e(B1e$B%S%C%HFI$a$P$$$$$b$N$rL5BL$KJ#;($K$d$C$F$$$^$;$s$+!#e(B

e$BA[DjMQES$,AH9~$_%/%i%9$N%F%9%H%1!<%[email protected]$H$9$k$H!"$&$l$7$$?M$O$H$F$be(B
e$B>/$J$=$&$G$9!#e(B
e$BB?>/>iD9$J=q$-J}$K$J$C$F$$$F$b$+$^$o$J$$$N$G$O!)e(B

e$BMQES$H$7$F$O$H$j$"$($:%F%9%H%1!<%9$J$N$G$9$,!"GX7J$H$7$F$Oe(B Float e$B$NIbF0>[email protected]?t$H$7$F$Ne(B
e$BFbIt9=B$$,1#JC$5$l$9$.$F$$$k$H$$$&[email protected]$rLdBj;k$7$F$$$^$9!#e(B
[email protected]$1$G$J$/!"e(BFloate$B$N2>?tIt$d;X?tIt$b$H$l$J$$$H$+!#e(B

e$B#C$G$b$H$l$J$$$G$9$h$Me(B > e$B2>?tIt!";X?tIte(B
e$B$G!"$=$l$G:$$k$H$$$&OC$b$"$^$jJ9$-$^$;$s!#e(B

Fortrane$B$de(BCe$B$G?tCM7W;;$9$k$H$-$b!"e(Bif (val < e$BL\[email protected]:EYe(B)
e$B$_$?$$$J=q$-J}$Ge(B
e$B$J$s$H$+$J$C$F$$$k$H$$$&G<1!#e(B

e$B$J$N$G!"$=$NGX7J$N$5$i$K%P%C%/%0%i%&%s%I$,$"$k$H;W$&$N$G$9$,!"e(B
e$B$A$g$C$H;W$$Ib$+$S$^$;$s$G$7$?!#e(B

e$B$($0$A!w%(%9%"%s%I%$!<$G$9e(B

2010e$BG/e(B3e$B7ne(B16e$BF|e(B14:03 NARUSE, Yui [email protected]:

%a e$BMm$_$N=hM}$r=q$$$F$$$F!"%P%$%J%j$H$7$F$O$9$0$=$3$K$"$k$O$:$N$b$N$,!e(B
Ruby e$B%l%$%[email protected]$H$+$J$j<j4V$r$+$1$J$$$H<h$l$J$$M}IT?T$5!$+$J!#e(B
e$B$o$?$7$,[email protected]$1$J$N$+$b$7$l$^$;$s$,!"8=>u;X?tIt!&2>?tIt$r<h$k$N$C$F!"e(B
e$B7k9=BgJQ$G$9$h$M!#e(B

packe$B%F%s%W%l!<%HJ8;zNse(B - Rubye$B%j%U%!%l%s%9%^%K%e%"%ke(B
http://www.ruby-lang.org/ja/man/html/pack_A5C6A5F3A5D7A5ECA1BCA5C8CAB8BBFACEF3.html
e$B!<!<!<e(B
IEEE754e$B=`5r$J4D6-$N>l9g!0J2<$N$h$&$K$7$FId9f!;X?tIt!"2>?tIt$r<h$j=P$;$^$9!#e(B
s = [v].pack(g).unpack(B*)[0][0,1] # e$BId9fe(B
e = [v].pack(g).unpack(B*)[0][1,8] # e$B;X?tIte(B
f = [v].pack(g).unpack(B*)[0][9,23] # e$B2>?tIte(B
e$B!<!<!<e(B

[email protected]$&J}K!$,$"$k$b$N$N!AH$9~$%a%=%C%I$K$$C$F$b0-$/$J$$$H;W$$$^$9!#e(B

e$B$($0$Ae(B

2010e$BG/e(B3e$B7ne(B16e$BF|e(B13:27 KOSAKI Motohiro
[email protected]:

e$B$7$+$7!"$3$NJ}K!$G$b$^[email protected]!e(B1e$B%S%C%HFI$a$P$$$$$b$N$rL5BL$KJ#;($K$d$C$F$$$^$;$s$+!#e(B
e$B$G!$=$l$G:$$k$H$$$&OC$b$"$^$jJ9$-$^$;$s!#e(B
frexp(3) e$B$G$H$l$^$9$M!#e(B

Fortrane$B$de(BCe$B$G?tCM7W;;$9$k$H$-$b!"e(Bif (val < e$BL\[email protected]:EYe(B) e$B$_$?$$$J=q$-J}$Ge(B
e$B$J$s$H$+$J$C$F$$$k$H$$$&G<1!#e(B

e$B$J$N$G!"$=$NGX7J$N$5$i$K%P%C%/%0%i%&%s%I$,$"$k$H;W$&$N$G$9$,!"e(B
e$B$A$g$C$H;W$$Ib$+$S$^$;$s$G$7$?!#e(B

%a
e$BMm$_$N=hM}$r=q$$$F$$$F!"%P%$%J%j$H$7$F$O$9$0$=$3$K$"$k$O$:$N$b$N$,!e(B
Ruby e$B%l%$%[email protected]$H$+$J$j<j4V$r$+$1$J$$$H<h$l$J$$M}IT?T$5!$+$J!#e(B
e$B$o$?$7$,[email protected]$1$J$N$+$b$7$l$^$;$s$,!"8=>u;X?tIt!&2>?tIt$r<h$k$N$C$F!"e(B
e$B7k9=BgJQ$G$9$h$M!#e(B

Fortrane$B$de(BCe$B$G?tCM7W;;$9$k$H$-$b!e(Bif (val < e$BL\[email protected]:EYe(B) e$B$_$?$$$J=q$-J}$Ge(B
e$B$$$d![email protected]$H;W$$$^$9!#e(B
e$B$J$N$G!%f!<%9%1!<%9$5$($$l$P$^$C$?$/H?BP$7$^$;$se(B

IEEE754e$BA0Ds$NDj5A!&<BAu$G$bC/$b:$$i$J$$$H;W$&$N$G!"$"$^$jYf$a$J$$$H;W$&$7e(B

e$B$5$i$K8e$+$i5$$,$D$-$^$7$?$,!e(BRubye$B$K$be(B Math.frexp()
e$B$,$9$G$K$$j$^$9$h$M!#e(B
e$B$3$l$GITB-$JM}M3$O$J$s$G$7$?$C$1!)e(B

2010e$BG/e(B3e$B7ne(B16e$BF|e(B15:16 KOSAKI Motohiro
[email protected]:

e$B$$$d![email protected]$H;W$$$^$9!#e(B
e$B$J$N$G!%f!<%9%1!<%9$5$($"$l$P$^$C$?$/H?BP$7$^$;$se(B

IEEE754e$BA0Ds$NDj5A!&<BAu$G$bC/$b:$$i$J$$$H;W$&$N$G!"$"$^$jYf$a$J$$$H;W$&$7e(B

e$B$5$i$K8e$+$i5$$,$D$-$^$7$?$,!e(BRubye$B$K$be(B Math.frexp() e$B$,$9$G$K$$j$^$9$h$M!#e(B
e$B$3$l$GITB-$JM}M3$O$J$s$G$7$?$C$1!)e(B

e$B$$$&!"$=$l$K5$$E$-$^$;$s$G$7$?!#e(B
e$B$=$l$G$h$$$H;W$$$^$9!#e(B

e$B$=$l$8$ce(B Math.signbit() e$B$,$"$l$P$$$$$Je(B

e$B#C$G$b$H$l$J$$$G$9$h$Me(B > e$B2>?tIt!";X?tIte(B
e$B$G!"$=$l$G:$$k$H$$$&OC$b$"$^$jJ9$-$^$;$s!#e(B

frexp(3) e$B$G$H$l$^$9$M!#e(B

e$BAG$GK:$l$F$$$^$7$?!#$4;XE&$"$j$,$H$&$4$6$$$^$9!#e(B
e$B$H$O$$$(!"e(Bgoogle code
searche$B$G8!:w$7$?$+$.$j$G$O!0UL#$N$$k1~MQ;vNc$re(B
e$B8+$D$1$i$l$^$;$s$G$7$?!#e(B

e$B7k9=BgJQ$G$9$h$M!#e(B
e$B$$$d![email protected]$H;W$$$^$9!#e(B
e$B$J$N$G!%f!<%9%1!<%9$5$($"$l$P$^$C$?$/H?BP$7$^$;$se(B

IEEE754e$BA0Ds$NDj5A!&<BAu$G$bC/$b:$$i$J$$$H;W$&$N$G!"$"$^$jYf$a$J$$$H;W$&$7e(B

e$B%A%1%C%He(B #2968 e$B$,99?7$5$l$^$7$?!#e(B (by Akinori MUSHA)

e$B%9%F!<%?%9e(B Rejectede$B$+$ie(BAssignede$B$KJQ99e(B
e$BC4Ev<Te(B Kenta M.e$B$K%;%C%He(B

e$B%U%#!<%I%P%C%/$,$"$k$N$Ke(BRejectede$B$N$^$^$J$N$G:F3+$7$^$9!#e(B

e$B!&e(Bpositive? e$B$Oe(B >0 e$B$G$bNI$$$N$GITMWe(B
e$B!&e(BMath.signbit?(num) [email protected]$H?7$7$$?t%/%i%9$KBP1~$G$-$J$$e(B

e$B$H$$$&$H$3$m$+$i!"e(B Numeric#negative?
e$B$rF3F~$9$k$N$O$G$I$&$G$7$g$&$+!#e(B
e$B!Je(BNumerice$B$G$NDj5A$Oe(Bnile$B$G!"Id9f$,[email protected]%/%i%9$G%*!<%P!<%i%$%I$7$Fe(Btrue/falsee$B$rJV$9!Ke(B

Numeric#sign e$B$b!"$"$l$PF1Id9fH=Dj$,3Z$K$J$k$+$b$7$l$^$;$s!#e(B

http://redmine.ruby-lang.org/issues/show/2968

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