HP Forums
nextprime function now working as expected with Ans - 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: nextprime function now working as expected with Ans (/thread-18592.html)



nextprime function now working as expected with Ans - lbundle - 07-26-2022 02:10 AM

I have just recently acquired an HP prime. I tried the nextprime(2) and it worked as expected giving the answer 3. I then tried nextprime(Ans), expecting to get 5. It returned 2. It seems nexrprime and Ans are not communicating for sme reason.

Or is there something I am doing wrong?


RE: nextprime function now working as expected with Ans - Stevetuc - 07-26-2022 04:12 AM

(07-26-2022 02:10 AM)lbundle Wrote:  I have just recently acquired an HP prime. I tried the nextprime(2) and it worked as expected giving the answer 3. I then tried nextprime(Ans), expecting to get 5. It returned 2. It seems nexrprime and Ans are not communicating for sme reason.

Or is there something I am doing wrong?

On the version of prime I am using on my phone
Software Version: 2.1.14346 (2019 11 21)
Hardware Version: Emu

nextprime(Ans) always returns 1.15951471769ᴇ15.
regardless of what Ans is preset to!
nextprime(Eval(Ans)) gives the expected result 5 when Ans is set to 3


RE: nextprime function now working as expected with Ans - Joe Horn - 07-26-2022 04:19 AM

The problem is caused by Prime having two different values of Ans, one for Home, and one for CAS. Since nextprime() is a CAS function, nextprime(Ans) always uses CAS's Ans, not Home's Ans. Does this mean that the HP Prime has multiple personality disorder? Yes, and it's scary because CAS's personality sneaks across into Home without warning, as you discovered.

Solution to this problem is simple: nextprime() and nextprime(Ans) work as desired in CAS view.


RE: nextprime function now working as expected with Ans - Joe Horn - 07-26-2022 04:22 AM

(07-26-2022 04:12 AM)Stevetuc Wrote:  nextprime(Ans) always returns 1.15951471769ᴇ15.
regardless of what Ans is preset to!
nextprime(Eval(Ans)) gives the expected result 5 when Ans is set to 3

The former (above) is using the Ans from CAS. Go into CAS, set its Ans to something, then go back to Home and set its Ans to something else. nextprime(Ans) will use the Ans from CAS, not the Ans from Home, even though you're in Home view.

The latter (above) is forcing Prime to use Home's Ans.

Crazy Prime. Sad


RE: nextprime function now working as expected with Ans - Albert Chan - 07-26-2022 01:06 PM

(07-26-2022 04:19 AM)Joe Horn Wrote:  The problem is caused by Prime having two different values of Ans, one for Home, and one for CAS.

We can get CAS Ans from Home side, with id(Ans)

Is there a way to get value of Home Ans, from CAS side?
(without switching to Home side to grab it, then switch back)


RE: nextprime function now working as expected with Ans - lbundle - 07-26-2022 04:48 PM

(07-26-2022 04:19 AM)Joe Horn Wrote:  The problem is caused by Prime having two different values of Ans, one for Home, and one for CAS. Since nextprime() is a CAS function, nextprime(Ans) always uses CAS's Ans, not Home's Ans. Does this mean that the HP Prime has multiple personality disorder? Yes, and it's scary because CAS's personality sneaks across into Home without warning, as you discovered.

Solution to this problem is simple: nextprime() and nextprime(Ans) work as desired in CAS view.

Is this supposed to be a feature or a bug? If it's a feature I cannot possibly see a use for it.


RE: nextprime function now working as expected with Ans - toml_12953 - 07-26-2022 06:10 PM

(07-26-2022 04:19 AM)Joe Horn Wrote:  The problem is caused by Prime having two different values of Ans, one for Home, and one for CAS. Since nextprime() is a CAS function, nextprime(Ans) always uses CAS's Ans, not Home's Ans. Does this mean that the HP Prime has multiple personality disorder? Yes, and it's scary because CAS's personality sneaks across into Home without warning, as you discovered.

This is why I always recommended that either

1) CAS and home be totally separate modes with no interaction. Those of us who have no need of CAS could ignore it.

or

2) CAS and home be totally integrated so that there was no division at all. You'd always be in a mode that could solve problems both numerically and exactly. Use a decimal point for approximation, or none for exact.

3.0 ÷ 4 = .75
3 ÷ 4 = ¾

TI's calculators have no problem doing this and neither do Casio's so I know it's not impossible.


RE: nextprime function now working as expected with Ans - cdmackay - 07-27-2022 11:54 AM

The 50g too.

I suspect the main reason was to use an existing, well-respected CAS pkg, rather than spend limited resources on developing a competing one, but that does then lead to the Home/CAS split.


RE: nextprime function now working as expected with Ans - John Keith - 07-27-2022 12:44 PM

The reason for the Home/CAS split is to comply with requirements for standardized testing. HP's market is education, not technical professionals. Much as I like the speed, larger memory and better display, I still use the 50g much more than the Prime.