Newsgroups: fj.lang.perl
Path: galaxy.trc.rwcp.or.jp!coconuts.jaist!wnoc-tyo-news!aist-nara!odins-suita!odins-toyonaka!ipcnews!tenjn02!tcn02!tr2244b!moriwaka
From: Kazuo Moriwaka <moriwaka@dw.kutc.kansai-u.ac.jp>
Subject: Re: [Q] How to avoid strings interpreted as 0 ?
Content-Type: text/plain; charset=ISO-2022-JP
Message-ID: <6b9vd4$hdm$1@tr2244b.res.kutc.kansai-u.ac.jp>
Lines: 43
Sender: @
Nntp-Posting-Host: tr2244b.res.kutc.kansai-u.ac.jp
Organization: Faculty of Informatics, Kansai University, Osaka, Japan.
X-Newsreader: mnews [version 1.20] 1996-12/08(Sun)
References: <87ra5la2lf.fsf@khaga.yacc.sei.co.jp>
Mime-Version: 1.0
Date: Wed, 4 Feb 1998 14:53:24 GMT
Xref: galaxy.trc.rwcp.or.jp fj.lang.perl:2532
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.lang.perl&nb=2532&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

$B?9<c!w4X@>Bg3XAm9g>pJs$G$9!#(B

// 1998$BG/(B02$B7n(B03$BF|$N8aA0(B10$B;~:"$K(B
    fj.lang.perl $B$X(B Koukichi HAGA $B$5$s$,Ej9F$5$l$?(B
     [Q] How to avoid strings interpreted as 0 ? $B$H$$$&5-;v$K$D$$$F!E!E(B //

($BN,(B)
> $B$N$h$&$J%9%/%j%W%H$K!"(B$n $B$H$7$F(B $B?t;z0J30$NJ8;zNs$rM?$($k$H(B
> $n == 0 $B$H2r<a$5$l$F$7$^$$!"%(%i!<%a%C%;!<%8(B(Input a numerical
> data !)$B$N=PNO$K$J$i$J$$$h$&$G$9!#(B
> 
> $B$I$N$h$&$J2r7h:v$,$"$k$+!"$*65$(2<$5$$!#(B

$B$Q$C$H;W$$$D$/HO0O$G$O!&!&!&(B
chomp(<>);
m/(\d+)/;
if (not defined $1) {
  $m = "Input a numerical data !\n";
} elsif ($1 > 0) {
  $m = 1 / sqrt ($1);
} elsif ($1 == 0) {
  $m = "infinity\n";
} elsif ($1 < 0) {
  $m = - 1 / sqrt ( - $1);
} 
print "$m";

$B$H$+!"(B

$n == 0 $B$r!"(B
$n == 0 and $n =~ m/0/ $B$K$9$k$H$+!"(B

$B$/$i$$$7$+;W$$$D$-$^$;$s!#(B
$B!t(Bperl$B$GC}$k$3$H$,$G$-$k?MC#$O$b$C$H3J9%$$$$2r$r=P$9$O$:!"B?J,(B :-)

$B!tH=Dj$N=g=x$O(B+, -, 0, NaN $B$NJ}$,$A$g$S$C$H8zN($$$$$+$b(B(^^;

$B$G$O$G$O!#(B
----------------------------------------
 \ /      \ /  | /  /\ |\ || / |  ||\ |  Kazuo Moriwaka 
 =| $B!&(B  $B!&(B |=  |/\ |~~|| \||/\ |  || \|  Faculty of informatics, Kansai Univ.
 / \      / \  |  \|  ||  ||  \|__||  |  email:fa50434@edu.kutc.kansai-u.ac.jp
----------------------------------------
