Post Reply 
(49G) Infinite Precision Integer to Infinite Precision Hexadecimal String & Back
06-03-2015, 05:22 PM (This post was last modified: 06-15-2017 01:45 PM by Gene.)
Post: #1
(49G) Infinite Precision Integer to Infinite Precision Hexadecimal String & Back
The programme takes an integer from the stack & returns a hexadecimal string of the same value.

eg For

88^88

otherwise known as

13015928349429720551826483074173153645387250759600678279153114847224523409663172​15805106820959190833309704934346517741237438752456673499160125624414995891111204​155079786496

the programme returns

# 0h

Well that's how it's displayed, as internally it's

HXS 00090 00000000000000000000000000000000000000000000000000000000000000000012963E64070DC5​067631DBD7DFC91FF0C596AB955B4B773D6D0FE8343051A0A7DE54C9933E8510

& all the lowest hex values are zero. However if you apply ->H to the result you will see how the number is stored internally, so it is really there.

Given this result as input the programme returns the original integer.


Code:
::
  CK1&Dispatch
  # FF
  ::
    FPTR2 ^DupQIsZero?
    casedrop
    HXS 00001 0
    FPTR2 ^Z>ZH
    # 2A4E
    CHANGETYPE
  ;
  BINT11
  ::
    # 2614
    CHANGETYPE
    DO>STR
    Z0_
    SWAP
    DUPLEN$
    #1+_ONE_DO
    DUPINDEX@
    SUB$1#
    BINT48
    #-
    FPTR2 ^#>Z
    ROT
    ZINT 16
    FPTR2 ^RMULText
    FPTR2 ^RADDext
    SWAPLOOP
    DROP
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




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