Post Reply 
(50g) Integer Square Root Rounded to Nearest Integer
09-06-2017, 07:37 AM (This post was last modified: 09-06-2017 02:08 PM by Gerald H.)
Post: #1
(50g) Integer Square Root Rounded to Nearest Integer
For integer input N the programme returns the square root rounded to the nearest integer.

Edit: Please do not use this programme - see latter postings.

Size: 193.

CkSum: # 300Eh

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
      FPTR2 ^ZSQ_
      ROT
      EQUAL
    ;
    case
    SWAPDROP
    DUPDUP
    FPTR2 ^RADDext
    ZINT 1
    FPTR2 ^RADDext
    FPTR2 ^ZSQ_
    ZINT 4
    FPTR2 ^ZDIVext
    DROPROT
    Z<
    NOT?SEMI
    ZINT 1
    FPTR2 ^RADDext
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(50g) Integer Square Root Rounded to Nearest Integer - Gerald H - 09-06-2017 07:37 AM



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