Post Reply 
Dismal Arithmetic & 3 Progs for 49G & Others
05-06-2015, 05:34 PM
Post: #12
RE: Dismal Arithmetic with Two Programmes for the HP 49G & the Prime
Here's a straight-forward UserRPL version I threw together on my 48SX. It's only intended to operate on non-negative integers; passing anything else has undefined results.

Code:
NUMLEN:
<<
  IF DUP 0 !=
  THEN ABS LOG 1 + IP
  END
>>

DIGIT:
<< 1 - ALOG / IP 10 MOD >>

DADD:
<< 0 0 -> A B C M
  << A NUMLEN B NUMLEN MAX 'M' STO
    1 M FOR I
      A I DIGIT B I DIGIT MAX I 1 - ALOG * 'C' STO+
    NEXT
    C
  >>
>>

DMULT:
<< 0 0 0 0 -> A B D M P S
  << B NUMLEN 'M' STO
    A NUMLEN
    IF DUP 0 !=
    THEN
      1 FOR I
        0 'P' STO A I DIGIT 'D' STO
        1 M FOR J
          B J DIGIT D MIN J 1 - ALOG * 'P' STO+
        NEXT
        S 10 * P DADD 'S' STO
      -1 STEP
      S
    END
  >>
>>

Usage is pretty straight-forward. Enter your two operands on the stack, and run DADD or DMULT. I might take a stab at doing a 32S version.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Dismal Arithmetic with Two Programmes for the HP 49G & the Prime - Dave Britten - 05-06-2015 05:34 PM



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