Post Reply 
Dismal Arithmetic & 3 Progs for 49G & Others
04-21-2015, 04:18 PM (This post was last modified: 09-08-2022 06:14 AM by Gerald H.)
Post: #1
Dismal Arithmetic & 3 Progs for 49G & Others
Dismal arithmetic was invented to help less proficient arithmeticians to achieve easier results. There are two operations, addition & multiplication.

Addition is no-carry & the sum of two digits is the larger of the two.

eg 123456789 + 987654321 = 987656789

Multiplication is no carry & the product of two digits is the lesser of the two.

eg 12345678901 * 7 = 12345677701

The first few dismal squares are:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100, 111, 112, 113, 114, 115, 116, 117, 118, 119, 200, 211....

For more see:

http://oeis.org/A087019

For more info & better explanations than I can give, try these three links:

https://proofwiki.org/wiki/Definition:Dismal_Addition

https://oeis.org/wiki/Dismal_arithmetic

http://arxiv.org/pdf/1107.1130.pdf

Two programmes for the HP 49G; DPLUS accomplishes dismal addition of two positive integers & DMULT the dismal multiplication of two positive integers.

DPLUS

Code:
::
  CK2&Dispatch
  # FFFF
  ::
    NULL$
    3UNROLL
    FPTR2 ^Z>S
    xSREV
    SWAP
    FPTR2 ^Z>S
    xSREV
    OVERLEN$
    OVERLEN$
    #MIN
    #1+_ONE_DO
    DUP
    CDR$
    SWAP
    CAR$
    ROTDUP
    CDR$
    3UNROLL
    CAR$
    2DUP#<
    ?SWAPDROP
    4ROLLSWAP
    >H$
    3UNROLL
    LOOP
    &$
    xSREV
    SWAP&$
    FPTR2 ^S>Z
  ;
;

DMULT

Code:
::
  CK2&Dispatch
  # FFFF
  ::
    DUP
    PTR 2F3A3
    COERCE
    DUP#0=csedrp
    FPTR2 ^2DROPZ0
    Z0_
    4UNROLL
    #1+_ONE_DO
    Z10_
    FPTR2 ^ZDIVext
    3PICKSWAP
    NULL$
    3UNROLL
    FPTR2 ^Z>S
    CAR$
    SWAP
    FPTR2 ^Z>S
    SWAP
    OVERLEN$
    #1+_ONE_DO
    DUPROT
    DUP
    CAR$
    SWAP
    CDR$
    4UNROLL
    2DUP#>
    ?SWAPDROP
    4ROLLSWAP
    >T$
    3UNROLL
    LOOP
    2DROP
    FPTR2 ^S>Z
    4ROLL
    ID DPLUS
    SWAPROT
    Z10_
    FPTR2 ^RMULText
    SWAPLOOP
    2DROP
  ;
;

I eagerly await the appearance of some dismal arithmetic programmes on the Prime.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 04-21-2015 04:18 PM



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