=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/real.c,v retrieving revision 1.4 retrieving revision 1.7 diff -u -p -r1.4 -r1.7 --- OpenXM_contrib2/asir2000/engine/real.c 2000/08/22 05:04:06 1.4 +++ OpenXM_contrib2/asir2000/engine/real.c 2001/10/09 01:36:13 1.7 @@ -45,93 +45,36 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/engine/real.c,v 1.3 2000/08/21 08:31:28 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/engine/real.c,v 1.6 2000/12/05 01:24:52 noro Exp $ */ #include "ca.h" #include "base.h" #include -#if defined(THINK_C) double RatnToReal(a) Q a; { - double nm,dn,t; - int enm,edn; - char buf[BUFSIZ]; - - nm = NatToReal(NM(a),&enm); - if ( INT(a) ) - if ( enm >= 1 ) - error("RatnToReal : Overflow"); - else - return SGN(a)>0 ? nm : -nm; - else { - dn = NatToReal(DN(a),&edn); - sprintf(buf,"1.0E%d",enm-edn); - sscanf(buf,"%lf",&t); - if ( SGN(a) < 0 ) - t = -t; - return nm/dn*t; - } -} - -double NatToReal(a,expo) -N a; -int *expo; -{ - int *p; - int l,all,i,j,s,tb,top,tail; - unsigned int t,m[2]; - - p = BD(a); l = PL(a) - 1; - for ( top = 0, t = p[l]; t; t >>= 1, top++ ); - all = top + BSH*l; tail = (53-top)%BSH; i = l-(53-top)/BSH-1; - m[1] = i < 0 ? 0 : p[i]>>(BSH-tail); - for ( j = 1, i++, tb = tail; i <= l; i++ ) { - s = 32-tb; t = i < 0 ? 0 : p[i]; - if ( BSH > s ) { - m[j] |= ((t&((1<>s; tb = BSH-s; - } - } else { - m[j] |= (t<= 1 ) + if ( enm >= 1 ) { error("RatnToReal : Overflow"); - else + /* NOTREACHED */ + return 0; + } else return SGN(a)>0 ? nm : -nm; else { dn = NatToReal(DN(a),&edn); man = nm/dn; if ( SGN(a) < 0 ) man = -man; - if ( ((e = enm - edn) >= 1024) || (e <= -1023) ) + if ( ((e = enm - edn) >= 1024) || (e <= -1023) ) { error("RatnToReal : Overflow"); /* XXX */ - else if ( !e ) + /* NOTREACHED */ + return 0; + } else if ( !e ) return man; else return man*pow(2,e); @@ -173,7 +116,6 @@ int *expo; #endif return *((double *)m); } -#endif void addreal(a,b,c) Num a,b; @@ -203,9 +145,11 @@ Real *c; *c = 0; else { t = ToReal(a)*ToReal(b); +#if 0 if ( !t ) error("mulreal : Underflow"); /* XXX */ else +#endif MKReal(t,*c); } } @@ -220,9 +164,11 @@ Real *c; *c = 0; else { t = ToReal(a)/ToReal(b); +#if 0 if ( !t ) error("divreal : Underflow"); /* XXX */ else +#endif MKReal(t,*c); } } @@ -255,16 +201,20 @@ Real *c; *c = 0; else if ( !RATN(b) || !INT(b) || (PL(NM((Q)b)) > 1) ) { t = (double)pow((double)ToReal(a),(double)ToReal(b)); +#if 0 if ( !t ) error("pwrreal : Underflow"); /* XXX */ else +#endif MKReal(t,*c); } else { t = pwrreal0(BDY((Real)a),BD(NM((Q)b))[0]); t = SGN((Q)b)>0?t:1/t; +#if 0 if ( !t ) error("pwrreal : Underflow"); /* XXX */ else +#endif MKReal(t,*c); } }