Post Reply 
HP49-HP50 : comparison of two "identical Matrixes"
12-08-2022, 03:11 PM
Post: #4
RE: HP49-HP50 : comparison of two "identical Matrixes"
(12-08-2022 12:51 PM)Gil Wrote:  But, why, when comparing the two integer identy Matrix do we get different objects?...

I'm surprised this issue doesn't come up more often.

Short answer: It's a bug. It affects a variety of operations that deal with exact integers on 49G-50g calculators.

Essentially, this is happening because there are two different ways for exact integers in the range -10..10 to be represented internally. While they represent the same values (there's no hidden digits), comparison operators don't always see them as being equal. If all of the values being compared are outside the range -10..10, this isn't an issue. It only affects that specific range of values.

Most math operations work as you would expect with both forms, but the results of the operations can be in either form and therefore checking for equality is hit-and-miss.

Here's another way to see the same issue. Try the following with the calculator in EXACT mode:
{ 1 2 3 }
{ 2 4 6 } 2 /
==
( or SAME, they both fail this test on a 50g)

Some operations work differently in specific ROM versions, so some of this actually works better on certain older versions. It just depends on the specific operations you are performing.

To make matters worse, some operations give one type of result for 0 and the other for 1..10 (or -1..-10).

If you are dealing with a square matrix, you could conceivably use a strategically-placed INV INV to "normalize" the values so that a comparison with the identity would succeed. You can probably see how that would get messy, though, depending on the contents of the matrices in question and what operations you are performing.

To deal with this when comparing lists, I resorted to creating special commands in the ListExt library that "normalize" -10..10 values anywhere in a list. You could convert the matrices to lists with AXL and then use LSAME to see if they match. It's a pain, but it works.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP49-HP50 : comparison of two "identical Matrixes" - DavidM - 12-08-2022 03:11 PM



User(s) browsing this thread: 1 Guest(s)