Changeset 1004
 Timestamp:
 Oct 3, 2011, 1:36:34 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/real.cpp
r1003 r1004 708 708 real sin(real const &x) 709 709 { 710 real ret = 0.0, fact = 1.0, xn = x, x2 = x * x; 711 710 bool switch_sign = x.m_signexp & 0x80000000u; 711 712 real absx = fmod(fabs(x), real::R_PI << 1); 713 if (absx > real::R_PI) 714 { 715 absx = real::R_PI; 716 switch_sign = !switch_sign; 717 } 718 719 if (absx > real::R_PI_2) 720 absx = real::R_PI  absx; 721 722 real ret = 0.0, fact = 1.0, xn = absx, x2 = absx * absx; 712 723 for (int i = 1; ; i += 2) 713 724 { … … 720 731 } 721 732 733 /* Propagate sign */ 734 if (switch_sign) 735 ret.m_signexp ^= 0x80000000u; 722 736 return ret; 723 737 } … … 725 739 real cos(real const &x) 726 740 { 727 real ret = 0.0, fact = 1.0, xn = 1.0, x2 = x * x; 728 741 bool switch_sign = false; 742 real absx = fmod(fabs(x), real::R_PI << 1); 743 744 if (absx > real::R_PI) 745 absx = (real::R_PI << 1)  absx; 746 747 if (absx > real::R_PI_2) 748 { 749 absx = real::R_PI  absx; 750 switch_sign = true; 751 } 752 753 real ret = 0.0, fact = 1.0, xn = 1.0, x2 = absx * absx; 729 754 for (int i = 1; ; i += 2) 730 755 { … … 737 762 } 738 763 764 /* Propagate sign */ 765 if (switch_sign) 766 ret.m_signexp ^= 0x80000000u; 739 767 return ret; 740 768 }
Note: See TracChangeset
for help on using the changeset viewer.