# HP Forums

Full Version: Bugs when using ANS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Software Version 2014 3 31 (6030)

1.| operator used on Ans in CAS return wrong answer.
2. approx(Ans) return wrong answer in Home (not from last element in History)

(06-19-2014 10:17 AM)slawek39 Wrote: [ -> ]1.| operator used on Ans in CAS return wrong answer.
What result would be expected if x isn't defined? What am I missing here?

Edit: Ah, sorry, I see it. Variable -a- could be replaced by 5 :-D.
The "a" should be changed to "5". It works directly on piecewise() funcrion, but not on Ans.
(06-19-2014 10:17 AM)slawek39 Wrote: [ -> ]2. approx(Ans) return wrong answer in Home (not from last element in History)

Yes, this is unexpected (and IMHO very annoying) but it's not really a bug. Here's why. There are two totally independent system variables which are both called Ans: one in Home, and one in CAS. All CAS functions (even when called from Home) use the CAS Ans. Since approx() is a CAS function, approx(Ans) will always use CAS's Ans (which is always whatever is at the bottom of the history stack in CAS), not Home's Ans (which is NOT always whatever is at the bottom of Home's history stack).

Try this:
CAS: 1+2 Enter --> 3
CAS: Ans Enter --> 3 (as expected)
Home: 5+6 Enter --> 11 (as expected)
Home: Ans Enter --> 11 (as expected)
Home: approx(Ans) --> 3 (yikes!!! it used CAS's Ans!)
Home: Ans --> 3 (Home's Ans got changed by the previous command!)

Solution: Use EVAL (Shift comma), not approx (Shift Enter) in Home when you want to evaluate Ans (or anything else):

CAS: 1+2 Enter --> 3
CAS: Ans Enter --> 3 (as expected)
Home: 5+6 Enter --> 11 (as expected)
Home: Ans Enter --> 11 (as expected)
Home: EVAL(Ans) --> 11 (ahh)

Personal opinion: Having two different values for Ans is a misfeature, since it makes Ans almost useless, since, to use Ans correctly, you have to memorize which functions are CAS functions and which are not. I hope that a future firmware update resolves this by having only one Ans, which is shared by both Home and CAS.
Or, just designate them correctly in the operating system, e.g., Home.Ans, and Cas.Ans.
If we use subst(Ans,a=5) instead of Ans|a=5 in CAS number 1 problem is solved.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :