Post Reply 
(49G) Z->B & B->Z full Accuracy
05-31-2015, 02:12 PM (This post was last modified: 06-15-2017 01:42 PM by Gene.)
Post: #1
(49G) Z->B & B->Z full Accuracy
The 49G converts zints to hexadecimal strings by R->B, first transforming the zint to a real & thereby loosing significant digits.

This programme does Z->B & B->Z to full accuracy.

eg For input

9898989898989898979

the programme returns

# 9898989898989898979d

& applying the programme again returns the original zint.

Code:
::
  CK1&Dispatch
  # FF
  ::
    BINT64
    dostws
    FPTR2 ^DupZIsNeg?
    casedrop
    HXS 00001 0
    ZINT 18446744073709551615
    FPTR2 ^ZNMin
    DUP
    FPTR2 ^Z>R
    %>#
    DUP
    HXS>%
    FPTR2 ^R>Z
    ROT
    FPTR2 ^RSUBext
    FPTR2 ^Z>R
    % 100000000.
    DUPUNROT
    %+SWAP
    %>#
    bit%#-
    bit-
  ;
  BINT11
  ::
    BINT64
    dostws
    DUP
    HXS>%
    DUP
    FPTR2 ^R>Z
    SWAPROT
    bit%#-
    % 100000000.
    DUPUNROT
    %>#
    bit+
    HXS>%
    SWAP
    %-
    FPTR2 ^R>Z
    FPTR2 ^RSUBext
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(49G) Z->B & B->Z full Accuracy - Gerald H - 05-31-2015 02:12 PM



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