Changeset baa707d in git for Singular/mpr_complex.cc


Ignore:
Timestamp:
Jul 2, 1999, 5:01:43 PM (25 years ago)
Author:
Moritz Wenk <wenk@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
78315991a696a660dd3d43059499d754ccf8c669
Parents:
1ce62fa5979699f05bc8ccbc453b8bfdafd92c1c
Message:
*wenk: fixed ngfRead and complex number output


git-svn-id: file:///usr/local/Singular/svn/trunk@3224 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/mpr_complex.cc

    r1ce62fa rbaa707d  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: mpr_complex.cc,v 1.9 1999-07-02 14:28:53 Singular Exp $ */
     4/* $Id: mpr_complex.cc,v 1.10 1999-07-02 15:01:43 wenk Exp $ */
    55
    66/*
     
    278278  if ( strlen(in) == 0 )
    279279  {
    280     *size= 2*sizeof(char)+10;
     280    *size= 2*sizeof(char);
    281281    out= (char*)AllocL( *size );
    282282    strcpy(out,"0");
     
    291291      int eexponent= (exponent >= 0) ? 0 : -exponent;
    292292      int eeexponent= (exponent >= 0) ? exponent : 0;
    293       *size= (strlen(in)+5+eexponent) * sizeof(char) + 10;
     293      *size= (strlen(in)+15+eexponent) * sizeof(char);
    294294      out= (char*)AllocL(*size);
    295       memset(out,'\0',*size);
     295      memset(out,0,*size);
    296296
    297297      strcpy(out,csign);
     
    311311    else if ( exponent+sign > (int)strlen(in) )
    312312    {
    313       *size= (strlen(in)+exponent+2)*sizeof(char)+10;
     313      *size= (strlen(in)+exponent+12)*sizeof(char);
    314314      out= (char*)AllocL(*size);
     315      memset(out,0,*size);
    315316      sprintf(out,"%s%s",csign,in+sign);
    316317      memset(out+strlen(out),'0',exponent-strlen(in)+sign);
     
    320321      *size= (strlen(in)+2) * sizeof(char) + 10;
    321322      out= (char*)AllocL(*size);
     323      memset(out,0,*size);
    322324      sprintf(out,"%s%s",csign,in+sign);
    323325    }
     
    335337      *size= (strlen(in)+12+c) * sizeof(char) + 10;
    336338      out= (char*)AllocL(*size);
     339      memset(out,0,*size);
    337340      sprintf(out,"%s0.%se%d",csign,in+sign,(unsigned int)exponent);
    338341//      }
     
    504507  if ( !c.imag().isZero() )
    505508  {
    506     in_real=floatToStr( c.real(), oprec );         // get real part
     509
     510      in_real=floatToStr( c.real(), oprec );         // get real part
    507511    in_imag=floatToStr( abs(c.imag()), oprec );    // get imaginary part
    508512
     
    512516      out=(char*)AllocL(len);
    513517      memset(out,0,len);
    514       sprintf(out,"%s%s%s*%s",in_real,c.imag().sign()>=0?"+":"-",currRing->parameter[0],in_imag);
     518      if (  !c.real().isZero() )
     519        sprintf(out,"(%s%s%s*%s)",in_real,c.imag().sign()>=0?"+":"-",currRing->parameter[0],in_imag);
     520      else
     521        sprintf(out,"(%s%s*%s)",c.imag().sign()>=0?"":"-",currRing->parameter[0],in_imag);
    515522    }
    516523    else
     
    519526      out=(char*)AllocL( len );
    520527      memset(out,0,len);
    521       sprintf(out,"%s%s%s",in_real,c.imag().sign()>=0?" + I ":" - I ",in_imag);
     528      if (  !c.real().isZero() )
     529        sprintf(out,"(%s%s%s)",in_real,c.imag().sign()>=0?"+I*":"-I*",in_imag);
     530      else
     531        sprintf(out,"(%s%s)",c.imag().sign()>=0?"I*":"-I*",in_imag);
    522532    }
    523533    FreeL( (ADDRESS) in_real );
    524534    FreeL( (ADDRESS) in_imag );
    525535  }
    526   else
     536  else 
    527537  {
    528538    out= floatToStr( c.real(), oprec );
    529539  }
     540
    530541  return out;
    531542}
Note: See TracChangeset for help on using the changeset viewer.