Changeset 1121
 Timestamp:
 Jan 2, 2012, 4:14:18 AM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/real.cpp
r1118 r1121 1269 1269 1270 1270 /* Normalise x so that mantissa is in [1..9.999] */ 1271 int exponent = 0; 1272 if (x.m_signexp) 1273 { 1274 for (real div = R_1, newdiv; true; div = newdiv) 1275 { 1276 newdiv = div * R_10; 1277 if (x < newdiv) 1278 { 1279 x /= div; 1280 break; 1281 } 1282 exponent++; 1283 } 1284 for (real mul = 1, newx; true; mul *= R_10) 1285 { 1286 newx = x * mul; 1287 if (newx >= R_1) 1288 { 1289 x = newx; 1290 break; 1291 } 1292 exponent; 1293 } 1271 /* FIXME: better use int64_t when the cast is implemented */ 1272 int exponent = ceil(log10(x)); 1273 x /= pow(R_10, (real)exponent); 1274 1275 if (x < R_1) 1276 { 1277 x *= R_10; 1278 exponent; 1294 1279 } 1295 1280 … … 1297 1282 for (int i = 0; i < ndigits; i++) 1298 1283 { 1299 int digit = (int) x;1284 int digit = (int)floor(x); 1300 1285 printf("%i", digit); 1301 1286 if (i == 0)
Note: See TracChangeset
for help on using the changeset viewer.