05-21-2015, 08:27 PM
Some time ago I wrote a programme to convert zints to long reals. Looking at the programme again, I realised it was only good for values < 10^500. Here's the old programme:
OLDPROG
::
CK1&Dispatch
# FF
::
DUPDUP
CODE 00025 143174E78FB9760131174143818F858DC7530
DUP
BINT13
#<
case2drop
FPTR2 ^Z2%%
BINT12
#-
Z10_
SWAP
FPTR2 ^PPow#
FPTR2 ^ZMod
DUPUNROT
FPTR2 ^RSUBext
FPTR2 ^Z2%%
SWAP
FPTR2 ^Z2%%
%%+
;
;
And here's the new programme good for zints as large as you like.
If anyone else has done this please tell me - improvements most welcome.
NEWPROG
::
CK1&Dispatch
# FF
::
FPTR2 ^DupZIsNeg?
ITE
%% -1E0
%%1
SWAP
FPTR2 ^ZAbs
DUP
FPTR2 ^Z>S
DUPLEN$
DUP
BINT13
#<
case2drop
::
FPTR2 ^Z2%%
%%*
;
ROTDROP
OVER
BINT1
BINT12
SUB$
FPTR2 ^S>Z
FPTR2 ^Z>R
%MANTISSA
%>%%
ROT
BINT13
BINT16
SUB$
FPTR2 ^S>Z
FPTR2 ^Z2%%
%% 1E15
%%/
%%+
%%10
ROT
#1-
FPTR2 ^PPow#
%%*
%%*
;
;
OLDPROG
::
CK1&Dispatch
# FF
::
DUPDUP
CODE 00025 143174E78FB9760131174143818F858DC7530
DUP
BINT13
#<
case2drop
FPTR2 ^Z2%%
BINT12
#-
Z10_
SWAP
FPTR2 ^PPow#
FPTR2 ^ZMod
DUPUNROT
FPTR2 ^RSUBext
FPTR2 ^Z2%%
SWAP
FPTR2 ^Z2%%
%%+
;
;
And here's the new programme good for zints as large as you like.
If anyone else has done this please tell me - improvements most welcome.
NEWPROG
::
CK1&Dispatch
# FF
::
FPTR2 ^DupZIsNeg?
ITE
%% -1E0
%%1
SWAP
FPTR2 ^ZAbs
DUP
FPTR2 ^Z>S
DUPLEN$
DUP
BINT13
#<
case2drop
::
FPTR2 ^Z2%%
%%*
;
ROTDROP
OVER
BINT1
BINT12
SUB$
FPTR2 ^S>Z
FPTR2 ^Z>R
%MANTISSA
%>%%
ROT
BINT13
BINT16
SUB$
FPTR2 ^S>Z
FPTR2 ^Z2%%
%% 1E15
%%/
%%+
%%10
ROT
#1-
FPTR2 ^PPow#
%%*
%%*
;
;