mirror of
https://gitee.com/openharmony/global_i18n
synced 2024-11-23 15:10:32 +00:00
!797 NumberFormat的size-file-byte支持设置小数位数
Merge pull request !797 from LY/master
This commit is contained in:
commit
9acd5f5eec
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user