
×InformationLearn how to upgrade to Windows 11

×InformationLearn how to upgrade to Windows 11
 HP Community
 >
 Other Products
 >
 Calculators
 >
 Program gives Syntax Error when run in RPN Mode
 Mark Topic as New
 Mark Topic as Read
 Float this Topic for Current User
 Bookmark
 Subscribe
 Mute
 Printer Friendly Page
Create an account on the HP Community to personalize your profile and ask a question
Solved!
Program gives Syntax Error when run in RPN Mode
03132020 01:55 PM
Hi,
Does anyone knwo why this works in Textbook mode but not RPN?
EXPORT BITSET(Word, BitNum)
BEGIN
LOCAL Tmp;
Tmp:= BITSL(SETBITS(#1,GETBITS(Word)), BitNum);
RETURN BITOR(Word, Tmp);
END;
I'm calling the program like this:
BITSET(#FEh,#0h)
In Textbook mode it gives #FFh as you'd expect but in RPN it give Syntax Error
Thanks.
Solved! Go to Solution.
Accepted Solutions
03142020 10:50 PM
The reason you're getting a Syntax Error is because you are using algebraic notation when you have your Prime set to expect Reverse Polish Notation. Algebraic entry mode expects the arguments of a function to follow the function name in parentheses, separated by commas, like this:
FOOBAR(5,6,7)
But RPN entry mode always expects the arguments to already be on the stack when the function is called, like this:
5 Enter 6 Enter 7 Enter FOOBAR
Prime uses a special RPN syntax which tells functions how many arguments to take from the stack, so in the above example, you might have to say FOOBAR(3) in RPN mode, which tells FOOBAR to take 3 arguments from the stack.
Therefore, in your example, I strongly suspect that you should put #FEh and #0h on the stack first, then execute either BITSET or BITSET(2). Please try that and let us know if it works.
Disclaimer: I don't work for HP. I'm just another happy HP calculator user.
03142020 10:50 PM
The reason you're getting a Syntax Error is because you are using algebraic notation when you have your Prime set to expect Reverse Polish Notation. Algebraic entry mode expects the arguments of a function to follow the function name in parentheses, separated by commas, like this:
FOOBAR(5,6,7)
But RPN entry mode always expects the arguments to already be on the stack when the function is called, like this:
5 Enter 6 Enter 7 Enter FOOBAR
Prime uses a special RPN syntax which tells functions how many arguments to take from the stack, so in the above example, you might have to say FOOBAR(3) in RPN mode, which tells FOOBAR to take 3 arguments from the stack.
Therefore, in your example, I strongly suspect that you should put #FEh and #0h on the stack first, then execute either BITSET or BITSET(2). Please try that and let us know if it works.
Disclaimer: I don't work for HP. I'm just another happy HP calculator user.

EnglishOpen Menu
Didn't find what you were looking for? Ask the community