Changeset 3053 in webkit for trunk/JavaScriptCore
- Timestamp:
- Dec 14, 2002, 7:33:10 PM (22 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r3051 r3053 1 2002-12-14 Maciej Stachowiak <[email protected]> 2 3 Reviewed by Ken. 4 5 - further corrections to number printing. 6 7 * kjs/ustring.cpp: 8 (UString::from): Make number printing match the ECMA standard 9 algorithm. 10 1 11 2002-12-14 Maciej Stachowiak <[email protected]> 2 12 -
trunk/JavaScriptCore/ChangeLog-2003-10-25
r3051 r3053 1 2002-12-14 Maciej Stachowiak <[email protected]> 2 3 Reviewed by Ken. 4 5 - further corrections to number printing. 6 7 * kjs/ustring.cpp: 8 (UString::from): Make number printing match the ECMA standard 9 algorithm. 10 1 11 2002-12-14 Maciej Stachowiak <[email protected]> 2 12 -
trunk/JavaScriptCore/kjs/ustring.cpp
r3051 r3053 337 337 int decimalPoint; 338 338 int sign; 339 340 char *result = kjs_dtoa(d, 5, 16, &decimalPoint, &sign, NULL);339 340 char *result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL); 341 341 int length = strlen(result); 342 342 … … 346 346 } 347 347 348 if (decimalPoint <= 0 ) {348 if (decimalPoint <= 0 && decimalPoint > -6) { 349 349 buf[i++] = '0'; 350 350 buf[i++] = '.'; … … 353 353 } 354 354 strcpy(buf + i, result); 355 } else if (decimalPoint >= length) { 355 } else if (decimalPoint <= 21 && decimalPoint > 0) { 356 if (length <= decimalPoint) { 357 strcpy(buf + i, result); 358 i += length; 359 for (int j = 0; j < decimalPoint - length; j++) { 360 buf[i++] = '0'; 361 } 362 buf[i] = '\0'; 363 } else { 364 strncpy(buf + i, result, decimalPoint); 365 i += decimalPoint; 366 buf[i++] = '.'; 367 strcpy(buf + i, result + decimalPoint); 368 } 369 } else if (result[0] < '0' || result[0] > '9') { 356 370 strcpy(buf + i, result); 357 371 } else { 358 strncpy(buf + i, result, decimalPoint); 359 i += decimalPoint; 360 buf[i++] = '.'; 361 strcpy(buf + i, result + decimalPoint); 362 } 372 buf[i++] = result[0]; 373 if (length > 1) { 374 buf[i++] = '.'; 375 strcpy(buf + i, result + 1); 376 i += length - 1; 377 } 378 379 buf[i++] = 'e'; 380 buf[i++] = (decimalPoint >= 0) ? '+' : '-'; 381 // decimalPoint can't be more than 3 digits decimal given the 382 // nature of float representation 383 int exponential = decimalPoint - 1; 384 if (exponential < 0) { 385 exponential = exponential * -1; 386 } 387 if (exponential >= 100) { 388 buf[i++] = '0' + exponential / 100; 389 } 390 if (exponential >= 10) { 391 buf[i++] = '0' + (exponential % 100) / 10; 392 } 393 buf[i++] = '0' + exponential % 10; 394 buf[i++] = '\0'; 395 } 396 363 397 kjs_freedtoa(result); 364 398
Note:
See TracChangeset
for help on using the changeset viewer.