Post Reply 
(50G) Integer to Hexadecimal Character String & Back
06-02-2015, 05:23 PM (This post was last modified: 06-15-2017 01:40 PM by Gene.)
Post: #1
(50G) Integer to Hexadecimal Character String & Back
The programme takes integer input & returns a character string of the hexadecimal value.

eg For input

18188037387806198379277339915556929647807403283187048631478337739929618787870634​227045716719924575689062274471430368865388203540672666042530996797

the programme returns

"5D3841172E8C2C2D55139C62DE05E1797BD976F2262E5225FC09438286F819EBF3A25CC8A629D8CC​762CB9D45A75B95074F2E0F7D47BDDDFC3157223D"

& applied to the result returns the original integer value.

Code:
::
  CK1&Dispatch
  # FF
  ::
    FPTR2 ^DupQIsZero?
    casedrop
    "0"
    FPTR2 ^Z>ZH
    FPTR 4 7
    BINT64
    BINT58
    DO
    INDEX@
    DUP
    #>CHR
    CHR>$
    SWAP
    #7+
    #>CHR
    CHR>$
    FPTR F 1A
    DROPLOOP
  ;
  BINT3
  ::
    DUPNULL$?
    caseSIZEERR
    DUP
    CAR$
    CHR_-
    EQUAL
    ITE
    ::
      CDR$
      TRUE
    ;
    FALSE
    SWAP
    Z0_
    SWAP
    DUPLEN$
    #1+_ONE_DO
    DUPINDEX@
    SUB$1#
    BINT48
    #-DUP
    BINT9
    #>
    IT
    #7-_
    FPTR2 ^#>Z
    ROT
    ZINT 16
    FPTR2 ^RMULText
    FPTR2 ^RADDext
    SWAPLOOP
    DROPSWAP
    NOT?SEMI
    FPTR2 ^RNEGext
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




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