How do I use CAS variables in a Program?
|
05-30-2017, 09:08 AM
Post: #1
|
|||
|
|||
How do I use CAS variables in a Program?
I want to use long integer values in a program. On the CAS home screen, I can define:
* A:=1000!; and it stores the exact value into that variable. I've tried methods I saw on various web pages, like * calling the variables CAS.B and CAS.D * CAS.B:=19^C-1; **** (I still got scientific notation when the numbers got too large) when that didn't work, I tried * CAS("B:=19^C-1"); **** but this still gave me scientific notation after a certain point. I'd love to know how to use CAS precision variables in a program if anyone can point me to the information. Here's the latest version of the program. It is meant to simply give the 2^E and 3^F prime factors of 19^C-1. Code:
(I don't know why this COPY of the program gets double ;; when I only used single ;. I assume there are some places where the ; is optional that I used it, so it was doubled when transferred to the computer. There are also some cases where I have ; in the calcuator and it was deleted when copied to the computer, like in both IF ... END blocks.) |
|||
05-30-2017, 04:54 PM
Post: #2
|
|||
|
|||
RE: How do I use CAS variables in a Program?
Certain system variables are always "Home" (i.e. non-CAS) variables, including A-Z (uppercase). The following notes might help:
http://www.hpmuseum.org/forum/thread-215.html Graph 3D | QPI | SolveSys |
|||
05-30-2017, 07:39 PM
Post: #3
|
|||
|
|||
RE: How do I use CAS variables in a Program?
Unfortunately, Han, I still cannot make this work for me.
Here is a simple program (double the value and add one) I tried several variations of, and I predefined the CAS variable aa in the CAS screen. Code:
When I run the program, it does not use the long precision, but instead drops it into scientific notation, and as you can see in the attached image, the new value of aa in the CAS window is also now in that notation. Perhaps it can't be done???? I look forward to any hints you can provide. |
|||
05-30-2017, 08:52 PM
(This post was last modified: 05-30-2017 08:52 PM by Tim Wessman.)
Post: #4
|
|||
|
|||
RE: How do I use CAS variables in a Program?
My best guess - "CAS." will be sending everything through the limited precision "home screen". Just remove all the CAS. and use aa directly since you are in a cas program.
In all honesty, CAS. does not really do anything and was purely to help users understand where an item was coming from. TW Although I work for HP, the views and opinions I post here are my own. |
|||
05-31-2017, 04:49 AM
Post: #5
|
|||
|
|||
RE: How do I use CAS variables in a Program?
Hello,
If your aim is to get long integers in home, then you can not do it as Home does not support long integers... The best that you CAN do is to use strings that will hold the representation of your long integer. in Home CAS(string(aa)) for example should return the string representation of the aa variable (which can contain a long integer). In this case, you need to make sure that you do all your calculations in CAS to ensure that there is not cas to home transform and loss of precision. Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
05-31-2017, 04:22 PM
Post: #6
|
|||
|
|||
RE: How do I use CAS variables in a Program?
(05-30-2017 08:52 PM)Tim Wessman Wrote: My best guess - "CAS." will be sending everything through the limited precision "home screen". Just remove all the CAS. and use aa directly since you are in a cas program. Thanks, I don't know why it didn't work the first time, but it worked this time. Perhaps it was because the first time, I didn't predefine the value in CAS mode. |
|||
05-31-2017, 04:23 PM
Post: #7
|
|||
|
|||
RE: How do I use CAS variables in a Program?
(05-31-2017 04:49 AM)cyrille de brébisson Wrote: If your aim is to get long integers in home, then you can not do it as Home does not support long integers... Thanks for your idea. I was able to do it without using strings. Perhaps you thought I wanted to use CAS variables in the non-cas HOME mode, but I was doing all my stuff in CAS mode and in a CAS program. It did ultimately work. |
|||
05-31-2017, 05:11 PM
Post: #8
|
|||
|
|||
RE: How do I use CAS variables in a Program?
(05-31-2017 04:22 PM)John@Mazes.com Wrote: Thanks, I don't know why it didn't work the first time, but it worked this time. Perhaps it was because the first time, I didn't predefine the value in CAS mode. It probably didn't work the first time because it wasn't within the #cas #end brackets. That throws the parser/compiler into/out of the "CAS" one which does runtime creation of stuff instead of compile time. TW Although I work for HP, the views and opinions I post here are my own. |
|||
06-01-2017, 03:50 AM
Post: #9
|
|||
|
|||
RE: How do I use CAS variables in a Program?
The CAS() command is a merely a "wrapper" command that enables non-CAS programs (i.e. "Home" programs) to execute CAS commands as if one were in the CAS view. The same goes for CAS.command() or CAS.object.
Since you used the #cas ... #end then you have already declared that everything enclosed within is to be treated as if run from the CAS view. So CAS.command() or CAS.object or even CAS("command or expression") is not only redundant but introduces possible conflicts in environments (CAS vs non-CAS). Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)