Post Reply 
Dismal Arithmetic & 3 Progs for 49G & Others
05-13-2015, 09:19 AM (This post was last modified: 09-08-2022 06:16 AM by Gerald H.)
Post: #23
RE: Dismal Arithmetic & 3 Progs for 49G & Others
Given DPLUS & DMULT prompts the question: What does DPOW do?

As repeated addition of n to n produces n, this possibility is discarded as being too dull even for dismals.

Conservatively, repeated multiplication looks like a promising candidate. Here again, single digit powering is of little interest, as eg

5 d^ 300000001 = 5

but for integers > 9 the results become interesting - hopefully not so interesting
that the operation is not regarded as dismal.

So here's a provisional programme using the provisional definition of Dpowering - I name the programme DPOW.

Enter positive integer n to power to positive integer power p, eg

123
4

produces

111122223.

DPOW

Code:
::
  CK2&Dispatch
  # FFFF
  ::
    FPTR2 ^DupQIsZero?
    case2drop
    Z1_
    FPTR2 ^DupZIsOne?
    caseDROP
    OVER
    PTR 2F3A3
    %2
    %<
    caseDROP
    OVERUNROT
    FPTR2 ^Z>ZH
    FPTR2 ^ZBits
    #1-
    ZERO_DO
    SWAPDUP
    ID DMULT
    SWAP
    ISTOP-INDEX
    #1-
    FPTR2 ^ZBit?
    IT
    ::
      SWAP3PICK
      ID DMULT
      SWAP
    ;
    LOOP
    DROPSWAPDROP
  ;
;

Alternative definitions of Dpowering welcome, programmes too.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 05-13-2015 09:19 AM



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