Math and NaN


#1

Math.sin e$B$Ke(B NaN e$B$rM?$($F$b$=$N$^$^e(B NaN
e$B$,JV$C$F$-$^$9$,!"e(BMath.sqrt e$B$O%(e(B
e$B%i!<$K$J$j$^$9!#?6Iq$$$,0l4S$7$F$$$J$$$h$&$K46$8$^$9!#e(B

main@191-20081211> NaN = 0.0/0
#=> NaN
main@191-20081211> Math.sin(NaN)
#=> NaN
main@191-20081211> Math.sqrt(NaN)
Errno::EDOM: Numerical argument out of domain - sqrt
from (irb):3:in sqrt' from (irb):3 from ./bin/irb:12:in

e$B$*$=$i$/!“e(Bsqrt
e$B$G$O!”$^$:Ii?t$K$D$$$F8!::$7$?$$$H$$$&$3$H$,$"$C$?$N$+$be(B
e$B$7$l$^$;$s$,!"e(BNaN e$B$K$D$$$F$O$I$&$J$N$G$7$g$&$+!#e(B

ruby e$B$G$NJ}?K$,H=$i$J$$$G$9$,!"$?$H$($P!"e(Bpython e$B$G$O!“e(BNaN
e$B$K$J$C$F$b!“e(B
e$BF~NO$,e(B NaN
e$B$G$”$l$P%(%i!<$K$O$7$J$$!”$H$$$&$h$&$K$J$C$F$$$k$h$&$G$9e(B
(python e$B$G$O!"e(B0.0/0 e$B$O%(%i!<$G$9e(B)e$B!#e(B


#2

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

In message “Re: [ruby-dev:37357] Math and NaN”
on Thu, 11 Dec 2008 01:31:26 +0900, Tadayoshi F.
removed_email_address@domain.invalid writes:

|Math.sin e$B$Ke(B NaN e$B$rM?$($F$b$=$N$^$^e(B NaN e$B$,JV$C$F$-$^$9$,!"e(BMath.sqrt e$B$O%(e(B
|e$B%i!<$K$J$j$^$9!#?6Iq$$$,0l4S$7$F$$$J$$$h$&$K46$8$^$9!#e(B

Rubye$B%l%Y%k$G$O$J$s$N%A%’%C%/$b$7$F$$$^$;$s$N$G!“e(B(e$B$”$kFCDj$Ne(B
e$B%W%i%C%H%U%)!<%`$K$*$1$ke(B)sqrt(3m)e$B$N5sF0$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ke(B
e$B$=$&$J$C$F$$$k$H;W$$$^$9!#e(B

sin(Inf) e$B$Ge(B NaN e$B$,JV$k$N$O!“Dj5A0h30$G$”$k$+$i$G!"e(BPython
e$B$G$O%(%i!<$K$Je(B
e$B$j$^$9$7!"e(BCommon Lisp
e$B$OI8=`$G$OL58BBg$J$I$J$$$G$9$,!“3HD%$H$7$FL58BBge(B
e$B$N$”$ke(B cmucl e$B$de(B sbcl e$B$G$bF1$8$G$9e(B
(e$B%H%i%C%W$r2r=|$9$k$3$H$b=PMh$^$9$,e(B)e$B!#e(B


#5

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

In message “Re: [ruby-dev:37413] Re: Math and NaN”
on Sat, 13 Dec 2008 09:32:56 +0900, Tadayoshi F.
removed_email_address@domain.invalid writes:

|e$B:#8=:_!"e(BMath.sin(Inf) e$B$J$I$G!“e(BNaN e$B$,JV$C$?>l9g$J$I$b$J$s$N8!::$b$J$$$Ge(B
|e$B$9$,!”$3$l$O$3$l$G$$$$$s$G$9$+$M!#e(B
|
|ruby e$B$G$O!“e(BNaN/0 e$B$J$I$N$h$&$J$b$N$b4^$a$F!”%(%i!<$K$J$i$J$$>l9g$,B?$/!“e(B
|sqrt(-1) e$B$de(B acos(-2) e$B$”$kFCDj$N$b$N$K$D$$$F%(%i!<$K$J$C$F$$$k$h$&$K8+$(e(B
|e$B$^$9!#e(B

Linuxe$B$Ne(Bmane$B$K!V%(%i!<!W%;%/%7%g%s$,$"$k$b$N$O%(%i!<$rJV$7$F$$e(B
e$B$k$h$&$J46$8$G$9$M!#e(B

|e$BB>$N8@8l$KHf$Y$FJ}?K$,H=$jFq$$$H$$$&$+!"$h$/H=$i$J$+$C$?$s$G$9$,!"$=$Ne(B
|e$B$"$?$j$NJ}?K$,$"$l$PCN$j$?$$$G$9!#e(B

e$B@5D>$J$H$3$m!"$"$s$^$j9M$($F$J$+$C$?!"$H$$$&$3$H$G$9$M!#e(B
e$B$I$&$9$k$N$,K>$^$7$$$H8@$&$N$,$"$l$P$*;G$$$7$?$$$G$9!#e(B


#6

In message removed_email_address@domain.invalid
on Mon, 15 Dec 2008 18:57:14 +0900,
Yukihiro M. removed_email_address@domain.invalid wrote:

|NaN e$B$K$J$C$F$b$=$N$^$^J|CV$7$F$k=hM}7O$,$+$J$jB?$$$H;W$$$^$9!#e(Bruby e$B%i%$e(B
|e$B%V%i%j$G$b0l@Z<j=P$7$7$J$$!"$H$$$&9M$($b$"$jF@$?$H;W$$$^$9!#e(B

e$B4pK\E*$K!"e(B

  • linux mane$B$G%(%i!<%;%/%7%g%s$,$"$k$b$N$K$D$$$Fe(Bnane$B$r%A%’%Ce(B
    e$B%/$9$ke(B

    e$B$H$7$F$$$?$N$G$9$,!$;2>H$7$F$$$?$N$OF|K\8l$Ne(Bmane$B$G!":#!“1Q8l$Ne(B
    mane$B$r%A%’%C%/$7$?$i$b$C$H>$7$/=q$$$F$”$j$^$9$M!"$&!<$`!#e(B
    e$B1Q8l$G$be(BLinuxe$B$Ne(Bmane$B$C$F!"$=$&$$$&$-$C$A$j$7$?3NG’$KBQ$(F@$k$b$N$J$se(B
    e$B$G$7$g$&$+!#e(B

(e$B$@$+$i!"$I$&$@$H$$$&$o$1$G$O$J$$$N$G$9$,!#e(B)


#7

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

In message “Re: [ruby-dev:37416] Re: Math and NaN”
on Sat, 13 Dec 2008 11:25:51 +0900, Tadayoshi F.
removed_email_address@domain.invalid writes:

|> e$B@5D>$J$H$3$m!"$"$s$^$j9M$($F$J$+$C$?!"$H$$$&$3$H$G$9$M!#e(B
|> e$B$I$&$9$k$N$,K>$^$7$$$H8@$&$N$,$"$l$P$*;G$$$7$?$$$G$9!#e(B
|
|e$B$I$&$$$&$N$,K>$^$7$$$N$+H=$j$^$;$s$,!“CfESH>C<$J46$8$,$7$^$9!#e(B
|
|NaN e$B$K$J$C$F$b$=$N$^$^J|CV$7$F$k=hM}7O$,$+$J$jB?$$$H;W$$$^$9!#e(Bruby e$B%i%$e(B
|e$B%V%i%j$G$b0l@Z<j=P$7$7$J$$!”$H$$$&9M$($b$"$jF@$?$H;W$$$^$9!#e(B

e$B4pK\E*$K!"e(B

  • linux mane$B$G%(%i!<%;%/%7%g%s$,$"$k$b$N$K$D$$$Fe(Bnane$B$r%A%’%Ce(B
    e$B%/$9$ke(B
  • e$BL58B$K$D$$$F8@5Z$,$"$k$b$N$Oe(Binfe$B$b%A%’%C%/$9$ke(B

e$B$H$7$F$$$?$N$G$9$,!$;2>H$7$F$$$?$N$OF|K\8l$Ne(Bmane$B$G!":#!“1Q8l$Ne(B
mane$B$r%A%’%C%/$7$?$i$b$C$H>$7$/=q$$$F$”$j$^$9$M!"$&!<$`!#e(B

e$BJ}?K$H$7$F$Oe(B

  • e$B0l@Z%A%’%C%/$7$J$$e(B
  • e$BA4It%A%’%C%/$9$ke(B

e$B$N$$$:$l$+$J$N$G$7$g$&$M!#$I$C$A$,$$$$$s$G$7$g$&$+!#<B:]$K;He(B
e$B$&?M$N0U8+$r$*$&$+$,$$$7$?$$$H$3$m$G$9!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

#8

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

In message “Re: [ruby-dev:37476] Re: Math and NaN”
on Wed, 17 Dec 2008 11:30:04 +0900, zunda removed_email_address@domain.invalid
writes:

|e$B?tCM1i;;$r$9$k>l9g$K$O!“A4It%A%’%C%/$7$FNc30$,>e$,$kJ}$,$&$l$7$$e(B
|e$B$G$9!#$”$k%G!<%?E@$Ge(BInfe$B$de(BNaNe$B$,=P$k$H%$%F%l!<%7%g%s$r=E$M$k$4$H$Ke(B
|e$B$=$l$,B>$N%G!<%?E@$K$bEAHB$7$F$$$C$FL50UL#$J7W;;$rB3$1$?>e$G!"e(B
|e$B$I$3$G$*$+$7$J7W;;$,5/$-$?$N$+C)$k$3$H$,$G$-$J$/$J$j$^$9!#e(B

e$B$J$k$[$I!#$H$J$k$H<B$Oe(BFloate$B$N=|;;$H$+$G$b@Q6KE*$KNc30$r$"$2e(B
e$B$?J}$,$&$l$7$$$H$$$&$3$H$J$s$G$9$+$M!#$=$&$$$($Pe(BPerle$B$de(BPython
e$B$O$=$&$7$F$$$k$h$&$G$9!#$$$d!"e(B1.9.1e$B$G$OJQ$($^$;$s$,!#e(B


#9

zundae$B$G$9e(B

e$B$*JV;v$,CY$/$J$C$F$7$^$$$^$7$?!#e(BCe$B$G$7$+!"$=$l$b$:$$$V$sA0$Ke(B
e$B$7$+;H$C$F$$$J$/$F62=L$G$9$,!"e(B

— Yukihiro M. removed_email_address@domain.invalid wrote:

In message “Re: [ruby-dev:37476] Re: Math and NaN”
on Wed, 17 Dec 2008 11:30:04 +0900, zunda removed_email_address@domain.invalid writes:

|e$B?tCM1i;;$r$9$k>l9g$K$O!“A4It%A%’%C%/$7$FNc30$,>e$,$kJ}$,$&$l$7$$e(B
|e$B$G$9!#$”$k%G!<%?E@$Ge(BInfe$B$de(BNaNe$B$,=P$k$H%$%F%l!<%7%g%s$r=E$M$k$4$H$Ke(B
|e$B$=$l$,B>$N%G!<%?E@$K$bEAHB$7$F$$$C$FL50UL#$J7W;;$rB3$1$?>e$G!"e(B
|e$B$I$3$G$*$+$7$J7W;;$,5/$-$?$N$+C)$k$3$H$,$G$-$J$/$J$j$^$9!#e(B

e$B$J$k$[$I!#$H$J$k$H<B$Oe(BFloate$B$N=|;;$H$+$G$b@Q6KE*$KNc30$r$"$2e(B
e$B$?J}$,$&$l$7$$$H$$$&$3$H$J$s$G$9$+$M!#e(B

e$B?tCM1i;;$K;H$&$H$$$&>lLL$K8B$C$F8@$($P$=$N$H$*$j$G$9!#e(B

e$B$=$&$$$($Pe(BPerle$B$de(BPython
e$B$O$=$&$7$F$$$k$h$&$G$9!#$$$d!"e(B1.9.1e$B$G$OJQ$($^$;$s$,!#e(B

e$B8=:_$"$^$j3hMQ$G$-$F$$$J$$$3$H$b$"$j!“6/$$0U8+$O$”$j$^$;$s!#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