Difference between revisions of "Talk:Not a Number"
(→One possibility for working with NaN: new section) |
Colin-adams (Talk | contribs) |
||
Line 24: | Line 24: | ||
end | end | ||
end | end | ||
+ | |||
+ | --[[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. |
Revision as of 02:17, 22 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.