Skip to content

Commit

Permalink
fix NaN comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
EzoeRyou committed Oct 27, 2019
1 parent 332338d commit b07ad25
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 108 deletions.
8 changes: 5 additions & 3 deletions 012-floating-point.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,18 @@ int main()
}
~~~

NaNとの比較結果はすべて`false`となる。
NaNとの比較結果はNaNと非NaNの非同値比較以外はすべて`false`となる。

~~~cpp
int main()
{
double NaN = std::numeric_limits<double>::quiet_NaN() ;

// すべてfalse
bool a = NaN == 0.0 ;
// true
bool b = NaN != 0.0 ;

// false
bool a = NaN == 0.0 ;
bool c = NaN == NaN ;
bool d = NaN != NaN ;
bool e = NaN < 0.0 ;
Expand Down
Loading

0 comments on commit b07ad25

Please sign in to comment.