Post Reply 
checkdigit calculation for HP-17b
07-28-2015, 02:54 PM
Post: #14
RE: checkdigit calculation for HP-17b
(07-26-2015 07:47 AM)Thomas Klemm Wrote:  
(07-26-2015 12:08 AM)Don Shepherd Wrote:  This reduced the size of the equation from 164 characters to 92 characters, a 44% reduction in size, and I achieved all of my goals.

We can go a little further:

CD = MOD(\(\Sigma\)(I:0:LOG(N):1:
L(A:MOD(IDIV(N:10^I):10)\(\times\)(MOD(I:2)-2))
+IDIV(G(A):10)
):10)

I moved the final negation into the expression so we have to calculate MOD 10 only once.
Instead of -9 we can use +1 when calculating MOD 10.
However I can't verify the formula at the moment.
Thus I could be completely wrong. Smile

Quote:The 17b is a great little machine and can exercise your mind in 2015 as well as it could in 1988.

Completely agree with you: I'm always happy when you bring it up.
The Luhn-algorithm was new to me. Thanks for letting us know.

Kind regards
Thomas

Thomas, it has taken me a couple of days but I finally figured out exactly how your method works. I had to draw a table taking things one step at a time, for each digit of the input number. What I couldn't figure out was the behavior of the MOD function with negative numbers; I've always stayed away from negative numbers before, but I now understand how MOD and INT work differently with negative numbers as opposed to positive numbers. I didn't realize that before, and I thank you for giving me this opportunity to understand that behavior.

Your method is a work of art. You are a "steely-eyed missleman", as NASA would say.

Don
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: checkdigit calculation for HP-17b - Don Shepherd - 07-28-2015 02:54 PM



User(s) browsing this thread: 3 Guest(s)