Changeset 1024
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/real.cpp
r1023 r1024 769 769 * off, but that's about it. */ 770 770 return (exp(x) + exp(-x)) >> 1; 771 } 772 773 real frexp(real const &x, int *exp) 774 { 775 if (!x) 776 { 777 *exp = 0; 778 return x; 779 } 780 781 real ret = x; 782 int exponent = (ret.m_signexp & 0x7fffffffu) - (1 << 30) + 1; 783 *exp = exponent + 1; 784 ret.m_signexp -= exponent + 1; 785 return ret; 786 } 787 788 real ldexp(real const &x, int exp) 789 { 790 real ret = x; 791 if (ret) 792 ret.m_signexp += exp; 793 return ret; 794 } 795 796 real modf(real const &x, real *iptr) 797 { 798 real absx = fabs(x); 799 real tmp = floor(absx); 800 801 *iptr = copysign(tmp, x); 802 return copysign(absx - tmp, x); 771 803 } 772 804 … … 1064 1096 } 1065 1097 1098 real atan2(real const &y, real const &x) 1099 { 1100 if (!y) 1101 { 1102 if ((x.m_signexp >> 31) == 0) 1103 return y; 1104 if (y.m_signexp >> 31) 1105 return -real::R_PI; 1106 return real::R_PI; 1107 } 1108 1109 if (!x) 1110 { 1111 if (y.m_signexp >> 31) 1112 return -real::R_PI; 1113 return real::R_PI; 1114 } 1115 1116 /* FIXME: handle the Inf and NaN cases */ 1117 real z = y / x; 1118 real ret = atan(z); 1119 if (x < real::R_0) 1120 ret += (y > real::R_0) ? real::R_PI : -real::R_PI; 1121 return ret; 1122 } 1123 1066 1124 void real::hexprint() const 1067 1125 { -
trunk/src/real.h
r1023 r1024 70 70 friend real acos(real const &x); 71 71 friend real atan(real const &x); 72 /* FIXME: atan2 */72 friend real atan2(real const &y, real const &x); 73 73 74 74 /* Hyperbolic functions */ … … 83 83 friend real log2(real const &x); 84 84 friend real log10(real const &x); 85 /* FIXME: frexp ldexp modf */ 85 friend real frexp(real const &x, int *exp); 86 friend real ldexp(real const &x, int exp); 87 friend real modf(real const &x, real *iptr); 86 88 87 89 /* Power functions */
Note: See TracChangeset
for help on using the changeset viewer.