Changeset baa707d in git for Singular/mpr_complex.cc
- Timestamp:
- Jul 2, 1999, 5:01:43 PM (25 years ago)
- Branches:
- (u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
- Children:
- 78315991a696a660dd3d43059499d754ccf8c669
- Parents:
- 1ce62fa5979699f05bc8ccbc453b8bfdafd92c1c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/mpr_complex.cc
r1ce62fa rbaa707d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mpr_complex.cc,v 1. 9 1999-07-02 14:28:53 SingularExp $ */4 /* $Id: mpr_complex.cc,v 1.10 1999-07-02 15:01:43 wenk Exp $ */ 5 5 6 6 /* … … 278 278 if ( strlen(in) == 0 ) 279 279 { 280 *size= 2*sizeof(char) +10;280 *size= 2*sizeof(char); 281 281 out= (char*)AllocL( *size ); 282 282 strcpy(out,"0"); … … 291 291 int eexponent= (exponent >= 0) ? 0 : -exponent; 292 292 int eeexponent= (exponent >= 0) ? exponent : 0; 293 *size= (strlen(in)+ 5+eexponent) * sizeof(char) + 10;293 *size= (strlen(in)+15+eexponent) * sizeof(char); 294 294 out= (char*)AllocL(*size); 295 memset(out, '\0',*size);295 memset(out,0,*size); 296 296 297 297 strcpy(out,csign); … … 311 311 else if ( exponent+sign > (int)strlen(in) ) 312 312 { 313 *size= (strlen(in)+exponent+ 2)*sizeof(char)+10;313 *size= (strlen(in)+exponent+12)*sizeof(char); 314 314 out= (char*)AllocL(*size); 315 memset(out,0,*size); 315 316 sprintf(out,"%s%s",csign,in+sign); 316 317 memset(out+strlen(out),'0',exponent-strlen(in)+sign); … … 320 321 *size= (strlen(in)+2) * sizeof(char) + 10; 321 322 out= (char*)AllocL(*size); 323 memset(out,0,*size); 322 324 sprintf(out,"%s%s",csign,in+sign); 323 325 } … … 335 337 *size= (strlen(in)+12+c) * sizeof(char) + 10; 336 338 out= (char*)AllocL(*size); 339 memset(out,0,*size); 337 340 sprintf(out,"%s0.%se%d",csign,in+sign,(unsigned int)exponent); 338 341 // } … … 504 507 if ( !c.imag().isZero() ) 505 508 { 506 in_real=floatToStr( c.real(), oprec ); // get real part 509 510 in_real=floatToStr( c.real(), oprec ); // get real part 507 511 in_imag=floatToStr( abs(c.imag()), oprec ); // get imaginary part 508 512 … … 512 516 out=(char*)AllocL(len); 513 517 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); 515 522 } 516 523 else … … 519 526 out=(char*)AllocL( len ); 520 527 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); 522 532 } 523 533 FreeL( (ADDRESS) in_real ); 524 534 FreeL( (ADDRESS) in_imag ); 525 535 } 526 else 536 else 527 537 { 528 538 out= floatToStr( c.real(), oprec ); 529 539 } 540 530 541 return out; 531 542 }
Note: See TracChangeset
for help on using the changeset viewer.