| [k,z,j,ierror]=xc210(k,z,j,ierror); |
function [k,z,j,ierror]=xc210(k,z,j,ierror);
persistent i ic id ii it ja ka ka1 ka2 m nm1 np1 ;
if isempty(i), i=0; end;
if isempty(ic), ic=0; end;
if isempty(id), id=0; end;
if isempty(ii), ii=0; end;
if isempty(it), it=0; end;
if isempty(ja), ja=0; end;
if isempty(ka), ka=0; end;
if isempty(ka1), ka1=0; end;
if isempty(ka2), ka2=0; end;
if isempty(m), m=0; end;
if isempty(nm1), nm1=0; end;
if isempty(np1), np1=0; end;
%***BEGIN PROLOGUE XC210
%***PURPOSE To provide single-precision floating-point arithmetic
% with an extended exponent range.
%***LIBRARY SLATEC
%***CATEGORY A3D
%***TYPE SINGLE PRECISION (XC210-S, DXC210-D)
%***KEYWORDS EXTENDED-RANGE SINGLE-PRECISION ARITHMETIC
%***AUTHOR Lozier, Daniel W., (National Bureau of Standards)
% Smith, John M., (NBS and George Mason University)
%***DESCRIPTION
% INTEGER K, J
% REAL Z
%
% GIVEN K THIS SUBROUTINE COMPUTES J AND Z
% SUCH THAT RADIX**K = Z*10**J, WHERE Z IS IN
% THE RANGE 1/10 .LE. Z .LT. 1.
% THE VALUE OF Z WILL BE ACCURATE TO FULL
% SINGLE-PRECISION PROVIDED THE NUMBER
% OF DECIMAL PLACES IN THE LARGEST
% INTEGER PLUS THE NUMBER OF DECIMAL
% PLACES CARRIED IN SINGLE-PRECISION DOES NOT
% EXCEED 60. XC210 IS CALLED BY SUBROUTINE
% XCON WHEN NECESSARY. THE USER SHOULD
% NEVER NEED TO CALL XC210 DIRECTLY.
%
%***SEE ALSO XSET
%***REFERENCES (NONE)
%***ROUTINES CALLED XERMSG
%***COMMON BLOCKS XBLK3
%***REVISION HISTORY (YYMMDD)
% 820712 DATE WRITTEN
% 890126 Revised to meet SLATEC CML recommendations. (DWL and JMS)
% 901019 Revisions to prologue. (DWL and WRB)
% 901106 Changed all specific intrinsics to generic. (WRB)
% Corrected order of sections in prologue and added TYPE
% section. (WRB)
% CALLs to XERROR changed to CALLs to XERMSG. (WRB)
% 920127 Revised PURPOSE section of prologue. (DWL)
%***end PROLOGUE XC210
global xblk3_1; if isempty(xblk3_1), xblk3_1=0; end;
global xblk3_2; if isempty(xblk3_2), xblk3_2=0; end;
global xblk3_3; if isempty(xblk3_3), xblk3_3=zeros(1,21); end;
% common :: ;
%% common /xblk3 / nlg102 , mlg102 , lg102(21);
%% common /xblk3 / xblk3_1 , xblk3_2 , xblk3_3(21);
% save :: ;
% save :: ;
%
% THE CONDITIONS IMPOSED ON NLG102, MLG102, AND LG102 BY
% THIS SUBROUTINE ARE
%
% (1) NLG102 .GE. 2
%
% (2) MLG102 .GE. 1
%
% (3) 2*MLG102*(MLG102 - 1) .LE. 2**NBITS - 1
%
% THESE CONDITIONS MUST BE MET BY APPROPRIATE CODING
% IN SUBROUTINE XSET.
%
%***FIRST EXECUTABLE STATEMENT XC210
ierror = 0;
if( k==0 )
j = 0;
z = 1.0;
else;
m = fix(xblk3_2);
ka = fix(abs(k));
ka1 = fix(fix(ka./m));
ka2 = fix(rem(ka,m));
if( ka1>=m )
% THIS ERROR OCCURS IF K EXCEEDS MLG102**2 - 1 IN MAGNITUDE.
%
xermsg('SLATEC','XC210','K too large',108,1);
ierror = 108;
return;
else;
nm1 = fix(xblk3_1 - 1);
np1 = fix(xblk3_1 + 1);
it = fix(ka2.*xblk3_3(np1));
ic = fix(fix(it./m));
id = fix(rem(it,m));
z = id;
if( ka1>0 )
for ii = 1 : nm1;
i = fix(np1 - ii);
it = fix(ka2.*xblk3_3(i) + ka1.*xblk3_3(i+1) + ic);
ic = fix(fix(it./m));
id = fix(rem(it,m));
z = z./m + id;
end; ii = fix(nm1+1);
ja = fix(ka.*xblk3_3(1) + ka1.*xblk3_3(2) + ic);
else;
for ii = 1 : nm1;
i = fix(np1 - ii);
it = fix(ka2.*xblk3_3(i) + ic);
ic = fix(fix(it./m));
id = fix(rem(it,m));
z = z./m + id;
end; ii = fix(nm1+1);
ja = fix(ka.*xblk3_3(1) + ic);
end;
z = z./m;
if( k>0 )
j = fix(ja + 1);
z = 10.0.^(z-1.0);
else;
j = fix(-ja);
z = 10.0.^(-z);
end;
end;
end;
end
%DECK XCON
|
|