mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 07:17:32 +09:00
Issue #1971 - Part 2: Update ICU source to 63.2.
This commit is contained in:
parent
8df84683be
commit
1e69214382
3160 changed files with 275815 additions and 234203 deletions
88
intl/icu/source/i18n/number_notation.cpp
Normal file
88
intl/icu/source/i18n/number_notation.cpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
// © 2017 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/numberformatter.h"
|
||||
#include "number_types.h"
|
||||
|
||||
using namespace icu;
|
||||
using namespace icu::number;
|
||||
using namespace icu::number::impl;
|
||||
|
||||
|
||||
ScientificNotation Notation::scientific() {
|
||||
// NOTE: ISO C++ does not allow C99 designated initializers.
|
||||
ScientificSettings settings;
|
||||
settings.fEngineeringInterval = 1;
|
||||
settings.fRequireMinInt = false;
|
||||
settings.fMinExponentDigits = 1;
|
||||
settings.fExponentSignDisplay = UNUM_SIGN_AUTO;
|
||||
NotationUnion union_;
|
||||
union_.scientific = settings;
|
||||
return {NTN_SCIENTIFIC, union_};
|
||||
}
|
||||
|
||||
ScientificNotation Notation::engineering() {
|
||||
ScientificSettings settings;
|
||||
settings.fEngineeringInterval = 3;
|
||||
settings.fRequireMinInt = false;
|
||||
settings.fMinExponentDigits = 1;
|
||||
settings.fExponentSignDisplay = UNUM_SIGN_AUTO;
|
||||
NotationUnion union_;
|
||||
union_.scientific = settings;
|
||||
return {NTN_SCIENTIFIC, union_};
|
||||
}
|
||||
|
||||
ScientificNotation::ScientificNotation(int8_t fEngineeringInterval, bool fRequireMinInt,
|
||||
impl::digits_t fMinExponentDigits,
|
||||
UNumberSignDisplay fExponentSignDisplay) {
|
||||
ScientificSettings settings;
|
||||
settings.fEngineeringInterval = fEngineeringInterval;
|
||||
settings.fRequireMinInt = fRequireMinInt;
|
||||
settings.fMinExponentDigits = fMinExponentDigits;
|
||||
settings.fExponentSignDisplay = fExponentSignDisplay;
|
||||
NotationUnion union_;
|
||||
union_.scientific = settings;
|
||||
*this = {NTN_SCIENTIFIC, union_};
|
||||
}
|
||||
|
||||
Notation Notation::compactShort() {
|
||||
NotationUnion union_;
|
||||
union_.compactStyle = CompactStyle::UNUM_SHORT;
|
||||
return {NTN_COMPACT, union_};
|
||||
}
|
||||
|
||||
Notation Notation::compactLong() {
|
||||
NotationUnion union_;
|
||||
union_.compactStyle = CompactStyle::UNUM_LONG;
|
||||
return {NTN_COMPACT, union_};
|
||||
}
|
||||
|
||||
Notation Notation::simple() {
|
||||
return {};
|
||||
}
|
||||
|
||||
ScientificNotation
|
||||
ScientificNotation::withMinExponentDigits(int32_t minExponentDigits) const {
|
||||
if (minExponentDigits >= 1 && minExponentDigits <= kMaxIntFracSig) {
|
||||
ScientificSettings settings = fUnion.scientific;
|
||||
settings.fMinExponentDigits = static_cast<digits_t>(minExponentDigits);
|
||||
NotationUnion union_ = {settings};
|
||||
return {NTN_SCIENTIFIC, union_};
|
||||
} else {
|
||||
return {U_NUMBER_ARG_OUTOFBOUNDS_ERROR};
|
||||
}
|
||||
}
|
||||
|
||||
ScientificNotation
|
||||
ScientificNotation::withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const {
|
||||
ScientificSettings settings = fUnion.scientific;
|
||||
settings.fExponentSignDisplay = exponentSignDisplay;
|
||||
NotationUnion union_ = {settings};
|
||||
return {NTN_SCIENTIFIC, union_};
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
Loading…
Add table
Add a link
Reference in a new issue