Changeset 994
 Timestamp:
 Sep 28, 2011, 7:04:44 PM (10 years ago)
 Location:
 trunk
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/real.cpp
r993 r994 349 349 real tmp = *this; 350 350 return *this = tmp / x; 351 } 352 353 real real::operator <<(int x) const 354 { 355 real tmp = *this; 356 return tmp <<= x; 357 } 358 359 real real::operator >>(int x) const 360 { 361 real tmp = *this; 362 return tmp >>= x; 363 } 364 365 real &real::operator <<=(int x) 366 { 367 if (m_signexp << 1) 368 m_signexp += x; 369 return *this; 370 } 371 372 real &real::operator >>=(int x) 373 { 374 if (m_signexp << 1) 375 m_signexp = x; 376 return *this; 351 377 } 352 378 … … 542 568 } 543 569 544 /* FIXME: sum.m_signexp += 2; (but needs private data access) */ 545 sum *= (real)4; 546 return z * sum; 570 return z * (sum << 2); 547 571 } 548 572 
trunk/src/real.h
r992 r994 47 47 real &operator /=(real const &x); 48 48 49 real operator <<(int x) const; 50 real operator >>(int x) const; 51 real &operator <<=(int x); 52 real &operator >>=(int x); 53 49 54 bool operator ==(real const &x) const; 50 55 bool operator !=(real const &x) const; 
trunk/test/unit/real.cpp
r982 r994 70 70 } 71 71 72 LOLUNIT_TEST( RealComparison)72 LOLUNIT_TEST(Comparison) 73 73 { 74 74 LOLUNIT_ASSERT(real(1.0f) > real(0.5f)); … … 91 91 } 92 92 93 LOLUNIT_TEST( RealAddition)93 LOLUNIT_TEST(Addition) 94 94 { 95 95 float a1 = real(1.0f) + real(0.0f); … … 113 113 } 114 114 115 LOLUNIT_TEST( RealSubtraction)115 LOLUNIT_TEST(Subtraction) 116 116 { 117 117 float a1 = real(1.0f) + real(1e20f)  real(1e20f); … … 120 120 } 121 121 122 LOLUNIT_TEST( RealMultiplication)122 LOLUNIT_TEST(Multiplication) 123 123 { 124 124 real x(1.25f); … … 138 138 } 139 139 140 LOLUNIT_TEST( RealDivision)140 LOLUNIT_TEST(Division) 141 141 { 142 142 real a1(1.0f); … … 155 155 LOLUNIT_ASSERT_EQUAL(m5, 0.5f); 156 156 } 157 158 LOLUNIT_TEST(Shift) 159 { 160 real a1(1.5); 161 real a2(1.5); 162 real a3(0.0); 163 164 LOLUNIT_ASSERT_EQUAL((double)(a1 >> 7), 0.01171875); 165 LOLUNIT_ASSERT_EQUAL((double)(a1 >> 7), 192.0); 166 LOLUNIT_ASSERT_EQUAL((double)(a1 << 7), 192.0); 167 LOLUNIT_ASSERT_EQUAL((double)(a1 << 7), 0.01171875); 168 169 LOLUNIT_ASSERT_EQUAL((double)(a2 >> 7), 0.01171875); 170 LOLUNIT_ASSERT_EQUAL((double)(a2 >> 7), 192.0); 171 LOLUNIT_ASSERT_EQUAL((double)(a2 << 7), 192.0); 172 LOLUNIT_ASSERT_EQUAL((double)(a2 << 7), 0.01171875); 173 174 LOLUNIT_ASSERT_EQUAL((double)(a3 >> 7), 0.0); 175 LOLUNIT_ASSERT_EQUAL((double)(a3 >> 7), 0.0); 176 LOLUNIT_ASSERT_EQUAL((double)(a3 << 7), 0.0); 177 LOLUNIT_ASSERT_EQUAL((double)(a3 << 7), 0.0); 178 } 157 179 }; 158 180
Note: See TracChangeset
for help on using the changeset viewer.