2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Perl のNaN 判定

Posted at

結論から書く

  • スクリプトの最初にdie "This perl does not support NaN!\n" if "NaN" == "NaN";と書く
  • 変数xがNaNか調べたいときは,x != xをチェックすれば良い。

Perl のNaN

  • Perlでは,NaNは何とも等しくならない値と定義されている。このため,"NaN" == "NaN"は偽となる。
  • ただし,古いバージョンなど一部の処理系では,'"NaN"'は0を返す文字列として扱われる。
  • このため,最初に手元の処理系が"NaN"をサポートしているかをチェックし,"NaN" != "NaN"の真偽を調べればよい。
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?