Problem in counting program
|
06-30-2020, 10:12 PM
(This post was last modified: 06-30-2020 10:13 PM by cahlucas.)
Post: #1
|
|||
|
|||
Problem in counting program
Hi all,
At the moment I am making some programs for digital technology. Now I'm working on a program to count the ones in a binary integer. So, if you have the number #264h (#1001100100b) as input, the number 4 appears as the result. It works the same as the #B function on the HP-16C or the nBITS function on the WP-34s. Now an error has crept into this program that I don't understand. If I input the number # 192837645h (# 110010010100000110111011001000101b) as input, I get the number 14 as a result, which should have been 15. The strange thing is that the outcome is correct for other inputs. The error occurs during debugging, at the BITAND function with mask # 0F0F0F0F0F0F0F0Fh, see the code below (I use double lowercase letters for my variable names to distinguish them from built-in variables). Attached is the HP-50g program from which I derived it, which works correctly. Can anyone help me with this problem? Sincerely, Karel. Code:
I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Problem in counting program - cahlucas - 06-30-2020 10:12 PM
RE: Problem in counting program - Joe Horn - 07-01-2020, 04:52 AM
RE: Problem in counting program - cahlucas - 07-01-2020, 06:55 AM
RE: Problem in counting program - Carlos295pz - 07-01-2020, 05:07 AM
RE: Problem in counting program - cahlucas - 07-01-2020, 07:01 AM
|
User(s) browsing this thread: 1 Guest(s)