+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
- * Copyright (C) 2015, International Business Machines
+ * Copyright (C) 2016, International Business Machines
* Corporation and others. All Rights Reserved.
*
* file name: visibledigits.cpp
return (fFlags & (kInfinite | kNaN)) != 0;
}
+UBool VisibleDigits::formatFullPrecision() const { // Apple
+ return fFormatFullPrecision;
+}
+void VisibleDigits::setFormatFullPrecision(UBool formatFullPrecision) { // Apple
+ fFormatFullPrecision = formatFullPrecision;
+}
+
double VisibleDigits::computeAbsDoubleValue() const {
// Take care of NaN and infinity
if (isNaN()) {
}
// stack allocate a decNumber to hold MAX_DBL_DIGITS+3 significant digits
- char rawNumber[sizeof(decNumber) + MAX_DBL_DIGITS+3];
- decNumber *numberPtr = (decNumber *) rawNumber;
+ struct {
+ decNumber decNum;
+ char digits[MAX_DBL_DIGITS+3];
+ } decNumberWithStorage;
+ decNumber *numberPtr = &decNumberWithStorage.decNum;
int32_t mostSig = fInterval.getMostSignificantExclusive();
int32_t mostSigNonZero = fExponent + fDigits.length();
char str[MAX_DBL_DIGITS+18];
uprv_decNumberToString(numberPtr, str);
U_ASSERT(uprv_strlen(str) < MAX_DBL_DIGITS+18);
- char decimalSeparator = DigitList::getStrtodDecimalSeparator();
- if (decimalSeparator != '.') {
- char *decimalPt = strchr(str, '.');
- if (decimalPt != NULL) {
- *decimalPt = decimalSeparator;
- }
- }
char *unused = NULL;
- return uprv_strtod(str, &unused);
+ return DigitList::decimalStrToDouble(str, &unused);
}
void VisibleDigits::getFixedDecimal(
// f (decimal digits)
// skip over any leading 0's in fraction digits.
int32_t idx = -1;
- for (; idx >= -v && getDigitByExponent(idx) == 0; --idx);
+ for (; idx >= -v && getDigitByExponent(idx) == 0; --idx)
+ ;
// Only process up to first 18 non zero fraction digits for decimalDigits
// since that is all we can fit into an int64.