HP Forums
(49G) Infinite Precision Integer to Infinite Precision Hexadecimal String & Back - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (49G) Infinite Precision Integer to Infinite Precision Hexadecimal String & Back (/thread-4065.html)



(49G) Infinite Precision Integer to Infinite Precision Hexadecimal String & Back - Gerald H - 06-03-2015 05:22 PM

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
  ;
;