Re: `== and nan - docs accuracy?
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmp983xf32LmHB0FAMk2TjYRp0vosdudoqENB8yEE1LFJQ@mail.gmail.com> |
On Fri, May 23, 2014 at 8:35 PM, Per Hedbor () @ Pike (-) importmöte för mailinglistan <[email protected]> wrote: >> This is correct behaviour per IEEE (NaN is not equal to anything, >> including itself), but the docs say that == returns true "iff the >> two floats are numerically equal or if both are NaN". Is this a docs >> bug, or is there something else going on here? > > Well. Considering these testsuite testcases: > > test_false( Math.nan == Math.nan ) > test_true( Math.nan != Math.nan ) > > I would consider it to be a documatation issue. Thanks for the confirmation. Patch attached to reword the docs. By the way, I only just discovered (by seeing something in the test suite) that the comparison functions allow more than two args, which are interpreted the same way as Python's chained comparisons. I think that's a great feature :) ChrisA
0001-Docs-fix-for-to-correct-the-explanation-of-float-flo.patch
(text/x-patch, 962 B)
From a66348e58cc4349090c2399ea72a95e056f84aff Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Fri, 23 May 2014 21:02:43 +1000 Subject: [PATCH] Docs fix for `==() to correct the explanation of float==float comparisons --- src/operators.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operators.c b/src/operators.c index 04e1b41..4d1c57b 100644 --- a/src/operators.c +++ b/src/operators.c @@ -1195,8 +1195,8 @@ PMOD_EXPORT void f_ne(INT32 args) *! @type int *! Successful iff the two integers are numerically equal. *! @type float - *! Successful iff the two floats are numerically equal or if - *! both are NaN. + *! Successful iff the two floats are numerically equal and + *! not NaN. *! @type string *! Successful iff the two strings are identical, character for *! character. (Since all strings are kept unique, this is -- 1.7.10.4