approx(Ans) oddity - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: approx(Ans) oddity (/thread-21066.html) |
approx(Ans) oddity - BruceH - 12-27-2023 05:01 PM Anyone seeing odd results coming from approx(Ans) in Home? On my G2 Prime, version 2023 04 13, which has been used for a bit of everything (programming, general calculations etc), I discovered by chance that approx(Ans) resulted in a 6 on the stack regardless of what was actually top. Just Ans on its own gave the top of stack as expected. A soft reset (On+Apps+Esc) wouldn't clear the problem. In the end I had to do a paperclip reset. Now I wonder what other oddities can be so persistent? RE: approx(Ans) oddity - Dougggg - 12-27-2023 06:27 PM It appears in my experience that approx is getting Ans from Cas not Home for me RE: approx(Ans) oddity - Joe Horn - 12-28-2023 12:39 AM (12-27-2023 06:27 PM)Dougggg Wrote: It appears in my experience that approx is getting Ans from Cas not Home for me That is correct. The approx() function is a CAS function, so approx(Ans) interprets "Ans" to mean the current value of CAS's Ans, which is different from Home's Ans. Similar unexpected results come from simplify(Ans) in Home, for the same reason. One way to evaluate Home's Ans when you're in Home view is EVAL(Ans), which thankfully is on the keyboard (Shift comma). RE: approx(Ans) oddity - Albert Chan - 12-28-2023 03:13 AM (12-28-2023 12:39 AM)Joe Horn Wrote: One way to evaluate Home's Ans when you're in Home view is EVAL(Ans) Nice trick! It would be even better if Ans really mean EVAL(Ans), by default. For now, this is a temporary fix. Code: EXPORT ANS() BEGIN EVAL(Ans); END; HOME> 1/(2+3/4) → 0.363636363636 HOME> exact(ANS) → 4/11 HOME> float(ANS) → 0.363636363636 RE: approx(Ans) oddity - BruceH - 12-28-2023 06:40 PM Thanks for the answers. It seems there is at least one definite bug and a second, possible bug. Firstly, I can repeat the issue by:
This is what I'm calling the possible bug because I feel that functions selected from the keyboard in Home mode, including ≈, should only be affected by whatever is set in Home. After all, SIN gives you SIN() in Home mode but sin() in CAS mode. Now
and you still get 6. This is the definite bug - both stacks were empty. RE: approx(Ans) oddity - gehakte_bits - 12-28-2023 08:12 PM See 'Ans' as a variable, not the last visible data on the stack. Clear the stack (shift-Clear) and recall Ans. A reset restored the last Ans prior to the reset. RE: approx(Ans) oddity - Wes Loewer - 12-28-2023 08:41 PM (12-28-2023 06:40 PM)BruceH Wrote: Now Ans gives the result of the last calculation, which is not necessarily the value at the bottom on the history. For example, enter the following. Code: 1+2 3 Now press the Del button until you only have Code: 1+2 3 If you now use Ans, it will return 11, not 3, since 11 was the last calculated result. Code: 1+2 3 Then there's the matter of clearing the memory. It seems that clearing the memory resets Home Ans to 0 but CAS Ans seems to survive the memory clear. This might actually be a bug. RE: approx(Ans) oddity - BruceH - 12-29-2023 12:34 AM Here's some more weirdness... Go into Home mode and do Ans(8), say, when the stack is empty or has fewer than 8 levels and you get "Error: invalid input" as you'd expect. Now do 'approx(Ans(8))' when the CAS stack is empty or has fewer than 8 levels. The answer you get is the same as 'approx(Ans)'. Looks like Ans is treated as an array in Home mode but not in CAS mode. I think we should have a go at trying to reach a consensus on what we think should happen so that if/when Moravia get a chance to do some bug fixing, we can at least be ready to show them what we'd like to see happen regarding Ans and Ans(). RE: approx(Ans) oddity - Joe Horn - 12-29-2023 01:20 PM (12-29-2023 12:34 AM)BruceH Wrote: Here's some more weirdness... [snip] These behaviors of Ans in Home and CAS are neither bugs nor weirdnesses. Press Ans Help to see the built-in Help screen about Ans, which details these behaviors. RE: approx(Ans) oddity - BruceH - 12-29-2023 01:36 PM Just because it's written down that it behaves weirdly and inconsistently doesn't mean that it isn't weird and inconsistent! :-)) But I take your point that I should have looked at the Help as being the most up to date documentation. My apologies for the noise. PS: In Home try Ans(-1). |