OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 1997-2014, International Business Machines Corporation and * | 3 * Copyright (C) 1997-2014, International Business Machines Corporation and * |
4 * others. All Rights Reserved. * | 4 * others. All Rights Reserved. * |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 * | 6 * |
7 * File DECIMFMT.CPP | 7 * File DECIMFMT.CPP |
8 * | 8 * |
9 * Modification History: | 9 * Modification History: |
10 * | 10 * |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 if (destIdx == noGroupingThreshold) { | 1443 if (destIdx == noGroupingThreshold) { |
1444 goto slowPath; | 1444 goto slowPath; |
1445 } | 1445 } |
1446 outputStr[--destIdx] = (n % 10) + kZero; | 1446 outputStr[--destIdx] = (n % 10) + kZero; |
1447 n /= 10; | 1447 n /= 10; |
1448 } | 1448 } |
1449 | 1449 |
1450 // Slide the number to the start of the output str | 1450 // Slide the number to the start of the output str |
1451 U_ASSERT(destIdx >= 0); | 1451 U_ASSERT(destIdx >= 0); |
1452 int32_t length = MAX_IDX - destIdx -1; | 1452 int32_t length = MAX_IDX - destIdx -1; |
1453 /*int32_t prefixLen = */ appendAffix(appendTo, number, handler, number<0, TR
UE); | 1453 /*int32_t prefixLen = */ appendAffix(appendTo, static_cast<double>(number),
handler, number<0, TRUE); |
1454 int32_t maxIntDig = getMaximumIntegerDigits(); | 1454 int32_t maxIntDig = getMaximumIntegerDigits(); |
1455 int32_t destlength = length<=maxIntDig?length:maxIntDig; // dest length pinn
ed to max int digits | 1455 int32_t destlength = length<=maxIntDig?length:maxIntDig; // dest length pinn
ed to max int digits |
1456 | 1456 |
1457 if(length>maxIntDig && fBoolFlags.contains(UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX
_DIGITS)) { | 1457 if(length>maxIntDig && fBoolFlags.contains(UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX
_DIGITS)) { |
1458 status = U_ILLEGAL_ARGUMENT_ERROR; | 1458 status = U_ILLEGAL_ARGUMENT_ERROR; |
1459 } | 1459 } |
1460 | 1460 |
1461 int32_t prependZero = getMinimumIntegerDigits() - destlength; | 1461 int32_t prependZero = getMinimumIntegerDigits() - destlength; |
1462 | 1462 |
1463 #ifdef FMT_DEBUG | 1463 #ifdef FMT_DEBUG |
1464 printf("prependZero=%d, length=%d, minintdig=%d maxintdig=%d destlength=%d s
kip=%d\n", prependZero, length, getMinimumIntegerDigits(), maxIntDig, destlength
, length-destlength); | 1464 printf("prependZero=%d, length=%d, minintdig=%d maxintdig=%d destlength=%d s
kip=%d\n", prependZero, length, getMinimumIntegerDigits(), maxIntDig, destlength
, length-destlength); |
1465 #endif | 1465 #endif |
1466 int32_t intBegin = appendTo.length(); | 1466 int32_t intBegin = appendTo.length(); |
1467 | 1467 |
1468 while((prependZero--)>0) { | 1468 while((prependZero--)>0) { |
1469 appendTo.append((UChar)0x0030); // '0' | 1469 appendTo.append((UChar)0x0030); // '0' |
1470 } | 1470 } |
1471 | 1471 |
1472 appendTo.append(outputStr+destIdx+ | 1472 appendTo.append(outputStr+destIdx+ |
1473 (length-destlength), // skip any leading digits | 1473 (length-destlength), // skip any leading digits |
1474 destlength); | 1474 destlength); |
1475 handler.addAttribute(kIntegerField, intBegin, appendTo.length()); | 1475 handler.addAttribute(kIntegerField, intBegin, appendTo.length()); |
1476 | 1476 |
1477 /*int32_t suffixLen =*/ appendAffix(appendTo, number, handler, number<0, FAL
SE); | 1477 /*int32_t suffixLen =*/ appendAffix(appendTo, static_cast<double>(number), h
andler, number<0, FALSE); |
1478 | 1478 |
1479 //outputStr[length]=0; | 1479 //outputStr[length]=0; |
1480 | 1480 |
1481 #ifdef FMT_DEBUG | 1481 #ifdef FMT_DEBUG |
1482 printf("Writing [%s] length [%d] max %d for [%d]\n", outputStr+destIdx,
length, MAX_IDX, number); | 1482 printf("Writing [%s] length [%d] max %d for [%d]\n", outputStr+destIdx,
length, MAX_IDX, number); |
1483 #endif | 1483 #endif |
1484 | 1484 |
1485 #undef kZero | 1485 #undef kZero |
1486 | 1486 |
1487 return appendTo; | 1487 return appendTo; |
(...skipping 4177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5665 } | 5665 } |
5666 } | 5666 } |
5667 } | 5667 } |
5668 } | 5668 } |
5669 | 5669 |
5670 U_NAMESPACE_END | 5670 U_NAMESPACE_END |
5671 | 5671 |
5672 #endif /* #if !UCONFIG_NO_FORMATTING */ | 5672 #endif /* #if !UCONFIG_NO_FORMATTING */ |
5673 | 5673 |
5674 //eof | 5674 //eof |
OLD | NEW |