トップページ > プログラム > 2020年03月29日 > sawiSEmu

書き込み順位&時間帯一覧

23 位/152 ID中時間01234567891011121314151617181920212223Total
書き込み数0100000000010000000000002



使用した名前一覧書き込んだスレッド一覧
デフォルトの名無しさん
C++相談室 part150

書き込みレス一覧

C++相談室 part150
28 :デフォルトの名無しさん[sage]:2020/03/29(日) 01:26:13.46 ID:sawiSEmu
>>23-24 少しでも被害者を減らすために issue 立てといてもらえませんかね?
C++相談室 part150
40 :デフォルトの名無しさん[sage]:2020/03/29(日) 11:22:58.32 ID:sawiSEmu
>>35
std::numeric_limits<T>::is_iec559 (IEEE 754) の場合は NaN!=NaN に定まる模様。
https://stackoverflow.com/questions/38798791/nan-comparison-rule-in-c-c
> I read the IEEE-754 rules on NaN, which states:
>> The comparisons EQ, GT, GE, LT, and LE, when either or both operands is NaN returns FALSE.
>> The comparison NE, when either or both operands is NaN returns TRUE.

C++の規定はこう。
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4849.pdf [expr.eq]
(C++14でも同じ https://timsong-cpp.github.io/cppwp/n4140/expr.eq#5 )
> If two operands compare equal, the result is true for the == operator
> and false for the != operator. If two operands compare unequal,
> the result is false for the == operator and true for the != operator.
> Otherwise, the result of each of the operators is unspecified.
これだけなら「equalでもunequalでもない」として結果を不定とする実装もあり得る。

ただしCの規定には以下のものがある。
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2454.pdf Equality operators
> The == (equal to) and != (not equal to) operators are ...
> For any pair of operands, exactly one of the relations is true.
これによれば NaN==NaN, NaN!=NaN を両方 false とするCの実装は許されない。
わざわざこれに反するようなC++の実装が作られる理由は無さそうだし、受け入れられることも無さそう。


※このページは、『2ちゃんねる』の書き込みを基に自動生成したものです。オリジナルはリンク先の2ちゃんねるの書き込みです。
※このサイトでオリジナルの書き込みについては対応できません。
※何か問題のある場合はメールをしてください。対応します。