Feature #2968: e$B?tCM$N@5Ii$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
e$B?tCM$N@5Ii$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, e$B@5$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:
e$B?tCM$N@5Ii$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, e$B@5$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
Amazonで島田 浩二, 設樂 洋爾, 村田 賢太, 前田 智樹, 谷口 文威のRuby 逆引きレシピ すぐに美味しいサンプル&テクニック 232 (PROGRAMMER’S RECIPE)。アマゾンならポイント還元本が多数。島田 浩二, 設樂 洋爾, 村田 賢太, 前田 智樹, 谷口 文威作品ほか、お急ぎ便対象商品は当日お届けも可能。またRuby 逆引きレシピ すぐに美味しいサンプル&テクニック 232 (PROGRAMMER’S RECIPE)もアマゾン配送商品なら通常配送無料。
E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: ドレッシングのような
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
e$B$G$O$J$s$G$@$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 e$B$G$O$J$s$G$@$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$^$@!"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
e$B$G$O$J$s$G$@$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$&0lE@5$$K$J$k$3$H$O!“e(B1.0 / -0.0 e$B$Ge(B -Infinity
e$B$,F@$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
Amazonで島田 浩二, 設樂 洋爾, 村田 賢太, 前田 智樹, 谷口 文威のRuby 逆引きレシピ すぐに美味しいサンプル&テクニック 232 (PROGRAMMER’S RECIPE)。アマゾンならポイント還元本が多数。島田 浩二, 設樂 洋爾, 村田 賢太, 前田 智樹, 谷口 文威作品ほか、お急ぎ便対象商品は当日お届けも可能。またRuby 逆引きレシピ すぐに美味しいサンプル&テクニック 232 (PROGRAMMER’S RECIPE)もアマゾン配送商品なら通常配送無料。
E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: ドレッシングのような
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
doublee$B$r@8@.$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 e$B$@$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 doublee$B$r@8@.$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
e$BJL$K@5IiH=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
e$B@.@%$G$9!#e (B
2010e$BG/e(B3e$B7ne(B16e$BF|e(B11:37 KOSAKI Motohiro
[email protected] :
e$B>/$J$=$&$G$9!#e (B
e$BB?>/>iD9$J=q$-J}$K$J$C$F$$$F$b$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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
e$B$H8@$&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$^$@!“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\I8@: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%$%d$@$H$+$J$j<j4V$r$+$1$J$$$H<h$l$J$$M}IT?T$5!”$+$J!#e (B
e$B$o$?$7$,CN$i$J$$$@$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\I8@:EYe(B) e$B$_$?$$$J=q$-J}$Ge(B
e$B$$$d!“BgJQ$J$N$O3N$+$@$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!“BgJQ$J$N$O3N$+$@$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!“BgJQ$J$N$O3N$+$@$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) e$B$@$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$,Dj5A$5$l$k3FGI@8%/%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