Changeset 982
 Timestamp:
 Sep 26, 2011, 2:00:52 AM (11 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/real.cpp
r976 r982 92 92 u.x <<= 4; 93 93 u.x = m_mantissa[3] >> 12; 94 /* Rounding */ 95 u.x += (m_mantissa[3] >> 11) & 1; 94 96 } 95 97 … … 110 112 111 113 /* Ensure both arguments are positive. Otherwise, switch signs, 112 * or replace + with  ). */114 * or replace + with . */ 113 115 if (m_signexp >> 31) 114 116 return (*this + x); 115 117 116 118 if (x.m_signexp >> 31) 117 return *this  x;119 return *this  (x); 118 120 119 121 /* Ensure *this is the larger exponent (no need to be strictly larger, … … 138 140 if (i  bigoff >= 0) 139 141 carry += x.m_mantissa[i  bigoff] >> off; 140 else if (i  bigoff == 1)141 carry += 0x0001u >> off;142 142 143 143 if (i  bigoff > 0) … … 172 172 173 173 /* Ensure both arguments are positive. Otherwise, switch signs, 174 * or replace  with + ). */174 * or replace  with +. */ 175 175 if (m_signexp >> 31) 176 176 return (*this + x); … … 207 207 if (i  bigoff >= 0) 208 208 carry = x.m_mantissa[i  bigoff] >> off; 209 else if (i  bigoff == 1)210 carry = 0x0001u >> off;211 209 212 210 if (i  bigoff > 0) … … 274 272 /* Accumulate low order product; no need to store it, we just 275 273 * want the carry value */ 276 uint 32_t carry = 0;274 uint64_t carry = 0; 277 275 for (int i = 0; i < BIGITS; i++) 278 276 { 279 277 for (int j = 0; j < i + 1; j++) 280 carry += m_mantissa[BIGITS  1  j]281 * x.m_mantissa[BIGITS  1 + j  i];278 carry += (uint32_t)m_mantissa[BIGITS  1  j] 279 * (uint32_t)x.m_mantissa[BIGITS  1 + j  i]; 282 280 carry >>= 16; 283 281 } … … 286 284 { 287 285 for (int j = i + 1; j < BIGITS; j++) 288 carry += m_mantissa[BIGITS  1  j]289 * x.m_mantissa[j  1  i];286 carry += (uint32_t)m_mantissa[BIGITS  1  j] 287 * (uint32_t)x.m_mantissa[j  1  i]; 290 288 291 289 carry += m_mantissa[BIGITS  1  i]; 
trunk/test/unit/real.cpp
r979 r982 98 98 float a4 = real(1.0f) + real(1.0f); 99 99 float a5 = real(1.0f) + real(0.125f); 100 double a6 = real(3.13609818956293918) 101 + real(0.00005972154828114); 102 float a7 = real(1.0f) + real(0.125f); 103 double a8 = real(0.10000000002) + real(2.0e11); 100 104 101 105 LOLUNIT_ASSERT_EQUAL(a1, 1.0f); … … 104 108 LOLUNIT_ASSERT_EQUAL(a4, 2.0f); 105 109 LOLUNIT_ASSERT_EQUAL(a5, 1.125f); 110 LOLUNIT_ASSERT_DOUBLES_EQUAL(a6, 3.1361579, 0.000001); 111 LOLUNIT_ASSERT_EQUAL(a7, 0.875f); 112 LOLUNIT_ASSERT_DOUBLES_EQUAL(a8, 0.1, 1.0e13); 106 113 } 107 114 … … 140 147 float m3 = a1 / a2; 141 148 float m4 = a2 / a2; 149 float m5 = a1 / a2; 142 150 143 151 LOLUNIT_ASSERT_EQUAL(m1, 1.0f); … … 145 153 LOLUNIT_ASSERT_EQUAL(m3, 0.5f); 146 154 LOLUNIT_ASSERT_EQUAL(m4, 1.0f); 155 LOLUNIT_ASSERT_EQUAL(m5, 0.5f); 147 156 } 148 157 };
Note: See TracChangeset
for help on using the changeset viewer.