Difference between revisions of "Talk:Not a Number"
(→One possibility for working with NaN: new section) |
Colin-adams (Talk | contribs) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
I was working on a project to represent complex numbers and used the following `is_equal' to accomodate the use of NaNs: | I was working on a project to represent complex numbers and used the following `is_equal' to accomodate the use of NaNs: | ||
− | + | <e> | |
is_equal (other: like Current): BOOLEAN | is_equal (other: like Current): BOOLEAN | ||
-- Is `other' attached to an object considered | -- Is `other' attached to an object considered | ||
Line 24: | Line 24: | ||
end | end | ||
end | end | ||
+ | </e> | ||
+ | |||
+ | --[[User:Colin-adams|Colin-adams]] 10:17, 22 February 2010 (UTC) Can you format that code? I can't follow it at all as it stands. | ||
+ | |||
+ | ---[[User:Peter gummer|Peter gummer]] 14:44, 22 February 2010 (UTC): Whoever pasted the code there had formatted it, but without suitable mark-up it came out on one line. I've added the mark-up ... how's that look now? | ||
+ | |||
+ | --[[User:Colin-adams|Colin-adams]] 14:27, 23 February 2010 (UTC)So that is pretending that two NaNs compare equal. Which is unsound. you are saying that the complex numbers (0/0, 1) and (0/0, 1) are equal. The whole problem arises because they are not comparable. |
Latest revision as of 05:27, 23 February 2010
--manus 19:37, 8 May 2007 (CEST): Have a look at Real Numbers page where we already started a similar discussion but currently only for the specification of REAL_64, not its usage.
One possibility for working with NaN
I was working on a project to represent complex numbers and used the following `is_equal' to accomodate the use of NaNs:
is_equal (other: like Current): BOOLEAN -- Is `other' attached to an object considered -- equal to current object? -- If current object is not a number (NaN) and -- `other' is as well `True' will be returned. do if is_nan then if real /~ real and then imaginary ~ imaginary then Result := real /~ other.real and then imaginary ~ other.imaginary elseif real ~ real and then imaginary /~ imaginary then Result := real ~ other.real and then imaginary /~ other.imaginary elseif real /~ real and then imaginary /~ imaginary then Result := real /~ other.real and then imaginary /~ other.imaginary end else Result := real ~ other.real and then imaginary ~ other.imaginary end end
--Colin-adams 10:17, 22 February 2010 (UTC) Can you format that code? I can't follow it at all as it stands.
---Peter gummer 14:44, 22 February 2010 (UTC): Whoever pasted the code there had formatted it, but without suitable mark-up it came out on one line. I've added the mark-up ... how's that look now?
--Colin-adams 14:27, 23 February 2010 (UTC)So that is pretending that two NaNs compare equal. Which is unsound. you are saying that the complex numbers (0/0, 1) and (0/0, 1) are equal. The whole problem arises because they are not comparable.