Changeset 990 for trunk/src/real.cpp
 Timestamp:
 Sep 28, 2011, 2:59:39 AM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/real.cpp
r988 r990 130 130 int off = e1  e2  bigoff * (sizeof(uint16_t) * 8); 131 131 132 if (bigoff > BIGITS) 133 return *this; 134 132 135 ret.m_signexp = m_signexp; 133 136 … … 188 191 int bigoff = (e1  e2) / (sizeof(uint16_t) * 8); 189 192 int off = e1  e2  bigoff * (sizeof(uint16_t) * 8); 193 194 if (bigoff > BIGITS) 195 return *this; 190 196 191 197 ret.m_signexp = m_signexp; … … 502 508 } 503 509 510 real fabs(real const &x) 511 { 512 real ret = x; 513 ret.m_signexp &= 0x7fffffffu; 514 return ret; 515 } 516 504 517 real exp(real const &x) 505 518 { … … 526 539 for (int i = 0; i < square; i++) 527 540 ret = ret * ret; 541 542 return ret; 543 } 544 545 real sin(real const &x) 546 { 547 real ret = 0.0, fact = 1.0, xn = x, x2 = x * x; 548 549 for (int i = 1; ; i += 2) 550 { 551 real newret = ret + xn / fact; 552 if (ret == newret) 553 break; 554 ret = newret; 555 xn *= x2; 556 fact *= (real)((i + 1) * (i + 2)); 557 } 558 559 return ret; 560 } 561 562 real cos(real const &x) 563 { 564 real ret = 0.0, fact = 1.0, xn = 1.0, x2 = x * x; 565 566 for (int i = 1; ; i += 2) 567 { 568 real newret = ret + xn / fact; 569 if (ret == newret) 570 break; 571 ret = newret; 572 xn *= x2; 573 fact *= (real)(i * (i + 1)); 574 } 528 575 529 576 return ret;
Note: See TracChangeset
for help on using the changeset viewer.