The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(49G) FPTR2^ZSQRT Replacement
05-14-2015, 02:50 PM (This post was last modified: 09-08-2017 04:40 PM by Gerald H.)
Post: #1
(49G) FPTR2^ZSQRT Replacement
Edit: Programme changed to remove uncommon names for pointers etc.

The built in integer square root-finder function returns the integer square root of N a positive integer & TRUE/FALSE if the square of the answer is exactly N or not. Sadly the square root of larger integers is not calculated correctly.

eg For entry

8057607683965968206853219945486680251051474004852138

FPTR2^ZSQRT returns

89764178177967899999999999 (incorrect value) & FALSE.

The programme below returns

89764178177967898147413811 (correct value) & FALSE.

Programme name: ISQRT

Size: 125.

CkSum: # 6291d

Code:
::
  CK1&Dispatch
  # FF
  ::
    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
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(49G) FPTR2^ZSQRT Replacement - Gerald H - 05-14-2015 02:50 PM



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