OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

# office-formula message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: RE: [office-formula] IMSUB and portable?

• From: "Dennis E. Hamilton" <dennis.hamilton@acm.org>
• To: "'Patrick Durusau'" <patrick@durusau.net>,<office-formula@lists.oasis-open.org>
• Date: Tue, 23 Mar 2010 09:42:49 -0700

```I don't believe this should be a note.  It can be removed.

Any user guide can provide this.  It is not necessary to the specification
or implementation of OpenFormula.

The observation made in the note is a consequence of the (mathematical)
definitions of IMABS and IMSUB.

Also, the note is about how to test complex numbers for (approximate)
equality when "=" is not defined for complex operands.  It is not about a
general test for equality of other things, only Complex Type values.  It
should not be used when neither of the operands are of Complex type or where
overflow of extreme numerical magnitudes is of concern.

- Dennis

Here's my understanding of this technique in the context of OpenFormula.

IMSUB(z1,z2) takes complex operands and produces a complex result, however
the operands are expressible for a given evaluator.  Typically, a Number
type value provided as z1 or z2 is automatically converted to a complex
value whose imaginary part is 0.  I haven't checked OpenFormula to verify
that is the case here, but I expect that it is.  If a text value is provided
for either of z1 or z2, the automatic conversion for that applies.  If it is
not convertible, there is an error value from IMSUB, of course.

IMABS(IMSUB(z1,z2)) is a simple non-complex magnitude that will be 0 when z1
and z2 are identical and a small Number value when they are nearly-identical
to within some notion of approximately-equal.  So one could test for near
identity using

IMABS(IMSUB(z1,z2)) <= approximately-0-tolerance-value

As in

IMABS(IMSUB(z1,z2)) <= 0 (or IMABS(IMSUB(z1,z2))=0 because IMABS is never
negative),

IMABS(IMSUB(z1,z2)) <= 0.5E-10,

and so on.

-----Original Message-----
From: Patrick Durusau [mailto:patrick@durusau.net]
Sent: Tuesday, March 23, 2010 07:51
To: office-formula@lists.oasis-open.org
Subject: [office-formula] IMSUB and portable?

Greetings!

Should the following be a note:

A portable way to test equality is to use IMSUB to compute the
difference, use IMABS to find the absolute difference, and then ensure the
absolute difference is smaller than or equal to some nonnegative value (for
exact equality, compare for equality with 0).

I ask because if an evaluator allows a TEXT type, IMSUB accepts complex. If
the TEXT is not converted into Complex, then how it this a portable test of
equality?

Seems to assume conversion to complex, which may not be the case.

Suggestions?

Thanks!

Patrick

--
Patrick Durusau
patrick@durusau.net
Chair, V1 - US TAG to JTC 1/SC 34
Convener, JTC 1/SC 34/WG 3 (Topic Maps)
Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300
Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps)

```

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]