[BACK]Return to spexpr.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / io

Diff for /OpenXM_contrib2/asir2000/io/spexpr.c between version 1.25 and 1.26

version 1.25, 2003/12/25 02:40:24 version 1.26, 2004/02/04 07:42:07
Line 44 
Line 44 
  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY   * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  * $OpenXM: OpenXM_contrib2/asir2000/io/spexpr.c,v 1.24 2003/06/09 16:18:10 saito Exp $  
 */  */
 #include "ca.h"  #include "ca.h"
 #include "al.h"  #include "al.h"
 #include "parse.h"  #include "parse.h"
 #include "comp.h"  #include "comp.h"
 #include "base.h"  #include "base.h"
 #if PARI  
   #if defined(PARI)
 #include "genpari.h"  #include "genpari.h"
 #endif  #endif
   
Line 70  int hex_output;
Line 70  int hex_output;
 int fortran_output;  int fortran_output;
 int double_output;  int double_output;
 int real_digit;  int real_digit;
   int real_binary;
 int print_quote;  int print_quote;
   
 #define TAIL  #define TAIL
Line 105  int print_quote;
Line 106  int print_quote;
 #define PRINTUP printup  #define PRINTUP printup
 #define PRINTUM printum  #define PRINTUM printum
 #define PRINTSF printsf  #define PRINTSF printsf
   #define PRINTSYMBOL printsymbol
 #endif  #endif
   
 #ifdef SPRINT  #ifdef SPRINT
Line 115  extern int hex_output;
Line 117  extern int hex_output;
 extern int fortran_output;  extern int fortran_output;
 extern int double_output;  extern int double_output;
 extern int real_digit;  extern int real_digit;
   extern int real_binary;
 extern int print_quote;  extern int print_quote;
   
   
Line 151  extern int print_quote;
Line 154  extern int print_quote;
 #define PRINTUP sprintup  #define PRINTUP sprintup
 #define PRINTUM sprintum  #define PRINTUM sprintum
 #define PRINTSF sprintsf  #define PRINTSF sprintsf
   #define PRINTSYMBOL sprintsymbol
 #endif  #endif
   
 void PRINTEXPR();  void PRINTEXPR();
Line 182  void PRINTEOP();
Line 186  void PRINTEOP();
 void PRINTLOP();  void PRINTLOP();
 void PRINTQOP();  void PRINTQOP();
 void PRINTSF();  void PRINTSF();
   void PRINTSYMBOL();
   
 #ifdef FPRINT  #ifdef FPRINT
 void output_init() {  void output_init() {
Line 292  Obj p;
Line 297  Obj p;
                         PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;                          PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;
                 case O_QUOTE:                  case O_QUOTE:
                         PRINTQUOTE(vl,(QUOTE)p); break;                          PRINTQUOTE(vl,(QUOTE)p); break;
                   case O_SYMBOL:
                           PRINTSYMBOL((Symbol)p); break;
                 default:                  default:
                         break;                          break;
         }          }
Line 393  Num q;
Line 400  Num q;
                                 case MID_PRINTF_G:                                  case MID_PRINTF_G:
 #endif  #endif
                                 default:                                  default:
                                         if ( real_digit ) {                                          if ( real_binary ) {
                                                   unsigned int *m;
                                                   unsigned int u,l,mask;
                                                   int i,expo;
   
                                                   m = (unsigned int *)&BDY((Real)q);
   #if defined(__i386__) || defined(MIPSEL) || defined(VISUAL) || defined(__alpha) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__x86_64)
                                                   u = m[1]; l = m[0];
   #else
                                                   u = m[0]; l = m[1];
   #endif
                                                   if (u&0x80000000) {
                                                           TAIL PRINTF(OUT,"-");
                                                   }
                                                   u &= 0x7fffffff;
                                                   expo = ((int)(u>>20));
                                                   u &= 0xfffff;
                                                   if ( expo == 2047 ) {
                                                           if ( u || l ) {
                                                                   TAIL PRINTF(OUT,"NaN");
                                                           } else {
                                                                   TAIL PRINTF(OUT,"Inf");
                                                           }
                                                   } else if ( expo == 0 ) {
                                                           if ( u || l ) {
                                                                   TAIL PRINTF(OUT,"0b0.");
                                                                   for ( i = 0, mask = 0x80000; i < 20;
                                                                           i++, mask >>= 1) {
                                                                           TAIL
                                                                           if ( u&mask )
                                                                                   PRINTF(OUT,"1");
                                                                           else
                                                                                   PRINTF(OUT,"0");
                                                                   }
                                                                   for ( i = 0, mask = 0x80000000; i < 32;
                                                                           i++, mask >>= 1) {
                                                                           TAIL
                                                                           if ( l&mask )
                                                                                   PRINTF(OUT,"1");
                                                                           else
                                                                                   PRINTF(OUT,"0");
                                                                   }
                                                                   TAIL PRINTF(OUT,"*2^%d",-1022);
                                                           } else {
                                                                   TAIL PRINTF(OUT,"0");
                                                           }
                                                   } else {
                                                           expo -= 1023;
                                                           TAIL PRINTF(OUT,"0b1.");
                                                           for ( i = 0, mask = 0x80000; i < 20;
                                                                   i++, mask >>= 1) {
                                                                   TAIL
                                                                   if ( u&mask )
                                                                           PRINTF(OUT,"1");
                                                                   else
                                                                           PRINTF(OUT,"0");
                                                           }
                                                           for ( i = 0, mask = 0x80000000; i < 32;
                                                                   i++, mask >>= 1) {
                                                                   TAIL
                                                                   if ( l&mask )
                                                                           PRINTF(OUT,"1");
                                                                   else
                                                                           PRINTF(OUT,"0");
                                                           }
                                                           if ( expo ) {
                                                                   TAIL PRINTF(OUT,"*2^%d",expo);
                                                           }
                                                   }
                                           } else if ( real_digit ) {
                                                 sprintf(real_format,                                                  sprintf(real_format,
                                                         double_output?"%%.%df":"%%.%dg",real_digit);                                                          double_output?"%%.%df":"%%.%dg",real_digit);
                                                 TAIL PRINTF(OUT,real_format,BDY((Real)q));                                                  TAIL PRINTF(OUT,real_format,BDY((Real)q));
Line 1098  unsigned int i;
Line 1174  unsigned int i;
         } else {          } else {
                 TAIL PRINTF(OUT,"@_%d",IFTOF(i));                  TAIL PRINTF(OUT,"@_%d",IFTOF(i));
         }          }
   }
   
   void PRINTSYMBOL(Symbol p)
   {
           PUTS(p->name);
 }  }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>