Changeset baa707d in git
 Timestamp:
 Jul 2, 1999, 5:01:43 PM (24 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
 Children:
 78315991a696a660dd3d43059499d754ccf8c669
 Parents:
 1ce62fa5979699f05bc8ccbc453b8bfdafd92c1c
 Location:
 Singular
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

Singular/gnumpfl.cc
r1ce62fa rbaa707d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: gnumpfl.cc,v 1. 5 19990702 14:28:52 SingularExp $ */4 /* $Id: gnumpfl.cc,v 1.6 19990702 15:01:42 wenk Exp $ */ 5 5 /* 6 6 * ABSTRACT: computations with GMP floatingpoint numbers … … 242 242 if ( exp == 0 ) 243 243 { 244 nNew(u);245 * (gmp_float*)u= (gmp_float)1.0;244 gmp_float* n = new gmp_float(1); 245 *u=(number)n; 246 246 return; 247 247 } … … 251 251 if ( x == NULL ) 252 252 { 253 *(gmp_float*)(*u) = (gmp_float)0.0; 253 gmp_float* n = new gmp_float(); 254 *u=(number)n; 254 255 } 255 256 else 256 257 { 257 *(gmp_float*)(*u) = *(gmp_float*)x; 258 gmp_float* n = new gmp_float(); 259 *n= *(gmp_float*)x; 260 *u=(number)n; 258 261 } 259 262 return; … … 262 265 ngfPower(x,exp1,u); 263 266 264 *(gmp_float*)(*u) *= *(gmp_float*)x; 267 gmp_float *n=new gmp_float(); 268 *n=*(gmp_float*)x; 269 *(gmp_float*)(*u) *= *(gmp_float*)n; 265 270 266 271 } … … 347 352 // eat floats (mantissa) like: 348 353 // 0.394394993, 102.203003008, .300303032 349 while ((*s >= '0' && *s <= '9')(*s == '.')) 350 { 351 s++; 352 } 354 while ((*s >= '0' && *s <= '9')(*s == '.')) s++; 355 353 356 // eat the exponent, starts with 'e' followed by '+', '' 354 // or no sign and digits, like: 355 // e1322, e202, e+393 356 if ( (s != start) && (*s == 'e') ) 357 { 358 s++; 359 if ( (*s=='')  (*s=='+') ) s++; 360 while ((*s >= '0' && *s <= '9')) 361 { 362 s++; 363 } 357 // and digits, like: 358 // e202, e+393 359 if ( (s != start) && (*s == 'e') && ((*(s+1) == '+')  (*(s+1) == '')) ) 360 { 361 s=s+2; // eat e and sign 362 while ((*s >= '0' && *s <= '9')) s++; 364 363 } 365 364 
Singular/mpr_complex.cc
r1ce62fa rbaa707d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mpr_complex.cc,v 1. 9 19990702 14:28:53 SingularExp $ */4 /* $Id: mpr_complex.cc,v 1.10 19990702 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',exponentstrlen(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.