It's a feature not a bug. IEEE 754 mandates that NAN is not equal to any other number including NAN itself (even if it's the same bit pattern). So if X != X, you know that X is NAN.
Ok, this takes a bit of thinking and explaining... eqv? makes sense; two NaNs act equivalently w.r.t. typical (arithmetic) operations.
eq? is questionable and may be non-portable. The significand of a NaN may carry a payload, and some hardware systems have rules for how that payload propagates. If your Scheme implementation gives access to those features, two NaNs may be not eq?. If it doesn't, then it makes sense for a system to say two NaNs are eq?.
equal? is determined by eqv?. That may be a poor choice here, but it's standard.
And = tests numeric equality. NaN is "Not a Number", hence not a numeric quantity. Including those in numerical relations is tricky. IEEE-754 also mandates that comparisons involving non-numeric quantities signal and invalid operation condition. Few programming systems provide access to the conditions, and most that do make them nigh impossible to use.
The rationale behind returning #f for = is to allow non-stop execution; you do not want to mandate new control paths. So the operation must return some value. Returning #t leads to many errors in existing, NaN-unaware codes. Returning #f allows codes to check for NaNs even if the programming system doesn't directly support them, so long as the test is not optimized out. So the standard chose #f.
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site. 야동
After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article. 국산야동
I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoy every little bit of it and I have you bookmarked to check out new stuff you post. 한국야동
7 comments:
It's a feature not a bug. IEEE 754 mandates that NAN is not equal to any other number including NAN itself (even if it's the same bit pattern). So if X != X, you know that X is NAN.
Ok, this takes a bit of thinking and explaining... eqv? makes sense; two NaNs act equivalently w.r.t. typical (arithmetic) operations.
eq? is questionable and may be non-portable. The significand of a NaN may carry a payload, and some hardware systems have rules for how that payload propagates. If your Scheme implementation gives access to those features, two NaNs may be not eq?. If it doesn't, then it makes sense for a system to say two NaNs are eq?.
equal? is determined by eqv?. That may be a poor choice here, but it's standard.
And = tests numeric equality. NaN is "Not a Number", hence not a numeric quantity. Including those in numerical relations is tricky. IEEE-754 also mandates that comparisons involving non-numeric quantities signal and invalid operation condition. Few programming systems provide access to the conditions, and most that do make them nigh impossible to use.
The rationale behind returning #f for = is to allow non-stop execution; you do not want to mandate new control paths. So the operation must return some value. Returning #t leads to many errors in existing, NaN-unaware codes. Returning #f allows codes to check for NaNs even if the programming system doesn't directly support them, so long as the test is not optimized out. So the standard chose #f.
All NaNs are equal?, but some are more = than others.
-- Paul
It was wondering if I could use this write-up on my other website, I will link it back to your website though. Great Thanks 한국야동
Also do visit may web page check this link 야설
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site. 야동
Also do visit may web page check this link 국산야동
After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article. 국산야동
Also do visit may web page check this link 한국야동
I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoy every little bit of it and I have you bookmarked to check out new stuff you post. 한국야동
Also do visit may web page check this link 야동
Post a Comment