HP Prime: Pass "Long" Integers to a Program

How can I make sure to pass an integer to a program, and not a real?

For example, calling MYPROG(11111111111111111111111199999) from CAS view results in "k" being real in EXPORT MYPROG(k). This causes problems with calling functions in the program that expect integers as arguments, e.g., isprime() or pa2b2() - - "Error: Bad argument type."

Thanks for any insights!


Here's one way to do it.

STEP 1: In CAS, define a function something like this:


In CAS mode, AA(123456789,987654321) returns the full 18-digit product, of course.

STEP 2: Go into the Program Catalog. Notice that it's now shown as a program which can be edited any way you like. For example, you can change the above AA program into:


This has the same effect as the above function when used in CAS mode, but now it looks more like a PPL program. The only real trick here is that you have to start with something saved in CAS mode, then edit it with the Program editor, then run it in CAS mode.

STEP 3: Have fun!


OK, I will try that out. Thanks so much!


Thanks, this works! :))

Only, don't clear the CAS history with "Clear" - - because then AA will be gone from the Program Catalog, as well as from the Memory Manager. Bug or Feature? :(


Only, don't clear the CAS history with "Clear" - - because then AA will be gone from the Program Catalog, as well as from the Memory Manager. Bug or Feature? :(
A known bug. It also resets all the CAS settings! Very annoying. I'm pi^4% sure that it'll be fixed in the next firmware version.

Sounds good - - let's cross our fingers!

I also noticed that programs with the CAS qualifier in parenthesis one cannot run from the program catalog - - the "run" soft key, as well as the "debug" soft key are missing.

Also, the "CAS" programs stay at the bottom list of the program catalog - - and when one edits them, on always has to hit "uparrow" twice in order to get to them. Other programs make it to the top of the catalog right away, which is nice for editing.


One more thing:

On the HP50G, the premise is that everything is an object and obeys the same rules. So, if your argument to a program is a long integer, a matrix, list, binary, complex number, algebraic expression, whatever - - you can pass it to your program with

<< -> k
<< do something here with k >>

and everything works beautifully.

On the Prime, however, you constantly need to be on the guard. Data types get converted, you need to be careful with CAS programs vs. Home programs, the program catalog "run" command only accepts reals, CAS commands don't accept functions you define with the "Define" key - - error message "Unmatch control word", RPN is an afterthought, lists can only have 999 elements, no compiled local variables, symbolic elements cannot be entered in to the matrix editor, etc. - -I could go on and on.

It seems to me that the "unifying" idea behind the Prime are the apps - - and that is OK for students, but how often do I use, say, the "Linear Explorer"? Even the "Solve" app is rudimentary (no complex solutions, and for more than univariate problems, the diagnostics are missing) and could be a lot better - - look, for example, at the "Solvesys" library for the 50G, which has been around for years - - I can't believe that HP couldn't take a clue from that.

Anyway, enough ranting - - I do like the speed of the Prime and the colors are great - - hopefully, things will flesh out over time. And using it interactively, it can be fun!

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending little images to the Prime (...and Program name bug?) Erwin Ried 19 7,332 12-10-2013, 05:35 PM
Last Post: Erwin Ried
  Problem with debug HP prime program, somebody help me? Carlos CM (Mexico) 6 3,332 12-05-2013, 03:07 PM
Last Post: Carlos CM (Mexico)
  HP PRIME: APP program code DISAPPEARS !! Joseph Ec 0 1,204 11-25-2013, 11:35 AM
Last Post: Joseph Ec
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 2,250 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  Prime: Program size limited to 64K? Erwin Ried 4 2,029 11-17-2013, 11:42 PM
Last Post: Joseph Ec
  [HP-Prime] Picking elements from a List in a program Jean-Michel 3 1,997 11-15-2013, 04:16 AM
Last Post: dg1969
  HP Prime: Recommendation for future RPN Program Mode BruceTTT 3 2,148 11-13-2013, 10:03 PM
Last Post: BruceTTT
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 2,699 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  [prime] Insert a breakpoint in a program for debugging ? Olivier Lecluse 3 1,776 11-09-2013, 09:41 PM
Last Post: Joseph Ec
  HP PRIME: Hide return value from program and swap Edit with Run vrrr 2 1,541 11-09-2013, 04:04 PM
Last Post: vrrr

Forum Jump: