!797 NumberFormat的size-file-byte支持设置小数位数

Merge pull request !797 from LY/master
This commit is contained in:
openharmony_ci 2024-08-23 05:15:23 +00:00 committed by Gitee
commit 9acd5f5eec
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 0 deletions

View File

@ -84,6 +84,7 @@ private:
std::string unitType;
std::string unitMeasSys;
bool createSuccess = false;
bool isSetFraction = false;
std::unique_ptr<LocaleInfo> localeInfo = nullptr;
std::unique_ptr<RelativeTimeFormat> relativeTimeFormat = nullptr;
icu::number::LocalizedNumberFormatter numberFormat;

View File

@ -217,6 +217,9 @@ void NumberFormat::InitDigitsProperties()
int32_t minFractionDigits = ConvertString2Int(minimumFractionDigits, minFdStatus);
int32_t maxFdStatus = 0;
int32_t maxFractionDigits = ConvertString2Int(maximumFractionDigits, maxFdStatus);
if (minFdStatus == 0 || maxFdStatus == 0) {
isSetFraction = true;
}
if (minFdStatus == 0 && maxFdStatus != 0) {
numberFormat =
numberFormat.precision(icu::number::Precision::minFraction(minFractionDigits));
@ -451,6 +454,9 @@ void NumberFormat::GetDigitsResolvedOptions(std::map<std::string, std::string> &
void NumberFormat::SetPrecisionWithByte(double number, const std::string& finalUnit)
{
if (isSetFraction) {
return;
}
int32_t FractionDigits = -1;
// 100 is the threshold between different decimal
if (finalUnit == "byte" || number >= 100) {