Post Reply 
(50g) Integer Square Root Rounded to Nearest Integer
09-06-2017, 02:20 PM
Post: #5
RE: (50g) Integer Square Root Rounded to Nearest Integer
Sorry, I thought I'd caught all the ?_ but hadn't.

Here a better version of the programme:

Size: 195.5

CkSum: # 782Ah

Code:
::
  CK1&Dispatch
  # FF
  ::
    DUP
    ::
      DUP
      ZINT 2
      Z<
      DUP
      ?SEMI
      DROPDUP
      FPTR2 ^Z>ZH
      FPTR2 ^ZBits
      BINT2
      #/
      #+
      ZINT 2
      SWAP
      FPTR2 ^PPow#
      BEGIN
      SWAPDROPDUP
      3PICKOVER
      FPTR2 ^ZQUOText
      FPTR2 ^QAdd
      ZINT 2
      FPTR2 ^ZQUOText
      2DUP
      Z>
      NOT_UNTIL
      DROPDUP
      DUP
      FPTR2 ^QMul
      ROT
      EQUAL
    ;
    DROP
    DUPDUP
    FPTR2 ^RADDext
    ZINT 1
    FPTR2 ^RADDext
    DUP
    FPTR2 ^QMul
    ZINT 4
    FPTR2 ^ZQUOText
    ROT
    Z<
    NOT?SEMI
    ZINT 1
    FPTR2 ^RADDext
  ;
;

Trust it compiles & works correctly.

^ZSQ_ is FPTR 6 590 which squares its argument.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (50g) Integer Square Root Rounded to Nearest Integer - Gerald H - 09-06-2017 02:20 PM



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