Skip to content

Commit

Permalink
ICU-22540 Add new CLDR units ronto, ronna, quecto, and quetta
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Oct 31, 2023
1 parent a7c7d8f commit 1bb711a
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
4 changes: 4 additions & 0 deletions icu4c/source/i18n/measunit_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const struct UnitPrefixStrings {
UMeasurePrefix value;
} gUnitPrefixStrings[] = {
// SI prefixes
{ "quetta", UMEASURE_PREFIX_QUETTA },
{ "ronna", UMEASURE_PREFIX_RONNA },
{ "yotta", UMEASURE_PREFIX_YOTTA },
{ "zetta", UMEASURE_PREFIX_ZETTA },
{ "exa", UMEASURE_PREFIX_EXA },
Expand All @@ -122,6 +124,8 @@ const struct UnitPrefixStrings {
{ "atto", UMEASURE_PREFIX_ATTO },
{ "zepto", UMEASURE_PREFIX_ZEPTO },
{ "yocto", UMEASURE_PREFIX_YOCTO },
{ "ronto", UMEASURE_PREFIX_RONTO },
{ "quecto", UMEASURE_PREFIX_QUECTO },
// Binary prefixes
{ "yobi", UMEASURE_PREFIX_YOBI },
{ "zebi", UMEASURE_PREFIX_ZEBI },
Expand Down
42 changes: 42 additions & 0 deletions icu4c/source/i18n/unicode/measunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,34 @@ typedef enum UMeasurePrefix {
*/
UMEASURE_PREFIX_YOTTA = UMEASURE_PREFIX_ONE + 24,

#ifndef U_HIDE_DRAFT_API
/**
* SI prefix: ronna, 10^27.
*
* @draft ICU 75
*/
UMEASURE_PREFIX_RONNA = UMEASURE_PREFIX_ONE + 27,

/**
* SI prefix: quetta, 10^30.
*
* @draft ICU 75
*/
UMEASURE_PREFIX_QUETTA = UMEASURE_PREFIX_ONE + 30,
#endif /* U_HIDE_DRAFT_API */

#ifndef U_HIDE_INTERNAL_API
/**
* ICU use only.
* Used to determine the set of base-10 SI prefixes.
* @internal
*/
#ifndef U_HIDE_DRAFT_API
UMEASURE_PREFIX_INTERNAL_MAX_SI = UMEASURE_PREFIX_QUETTA,
#else /* U_HIDE_DRAFT_API */
UMEASURE_PREFIX_INTERNAL_MAX_SI = UMEASURE_PREFIX_YOTTA,
#endif /* U_HIDE_DRAFT_API */

#endif /* U_HIDE_INTERNAL_API */

/**
Expand Down Expand Up @@ -249,13 +270,34 @@ typedef enum UMeasurePrefix {
*/
UMEASURE_PREFIX_YOCTO = UMEASURE_PREFIX_ONE + -24,

#ifndef U_HIDE_DRAFT_API
/**
* SI prefix: ronto, 10^-27.
*
* @draft ICU 75
*/
UMEASURE_PREFIX_RONTO = UMEASURE_PREFIX_ONE + -27,

/**
* SI prefix: quecto, 10^-30.
*
* @draft ICU 75
*/
UMEASURE_PREFIX_QUECTO = UMEASURE_PREFIX_ONE + -30,
#endif /* U_HIDE_DRAFT_API */

#ifndef U_HIDE_INTERNAL_API
/**
* ICU use only.
* Used to determine the set of base-10 SI prefixes.
* @internal
*/
#ifndef U_HIDE_DRAFT_API
UMEASURE_PREFIX_INTERNAL_MIN_SI = UMEASURE_PREFIX_QUECTO,
#else /* U_HIDE_DRAFT_API */
UMEASURE_PREFIX_INTERNAL_MIN_SI = UMEASURE_PREFIX_YOCTO,
#endif /* U_HIDE_DRAFT_API */

#endif // U_HIDE_INTERNAL_API

// Cannot conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/test/intltest/measfmttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5743,6 +5743,8 @@ void MeasureFormatTest::TestPrefixes() {
int32_t expectedBase;
int32_t expectedPower;
} cases[] = {
{UMEASURE_PREFIX_QUECTO, 10, -30},
{UMEASURE_PREFIX_RONTO, 10, -27},
{UMEASURE_PREFIX_YOCTO, 10, -24},
{UMEASURE_PREFIX_ZEPTO, 10, -21},
{UMEASURE_PREFIX_ATTO, 10, -18},
Expand All @@ -5764,6 +5766,8 @@ void MeasureFormatTest::TestPrefixes() {
{UMEASURE_PREFIX_EXA, 10, 18},
{UMEASURE_PREFIX_ZETTA, 10, 21},
{UMEASURE_PREFIX_YOTTA, 10, 24},
{UMEASURE_PREFIX_RONNA, 10, 27},
{UMEASURE_PREFIX_QUETTA, 10, 30},
{UMEASURE_PREFIX_KIBI, 1024, 1},
{UMEASURE_PREFIX_MEBI, 1024, 2},
{UMEASURE_PREFIX_GIBI, 1024, 3},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4623,6 +4623,8 @@ class TestCase {
}

TestCase cases[] = {
new TestCase(MeasureUnit.MeasurePrefix.QUECTO, 10, -30),
new TestCase(MeasureUnit.MeasurePrefix.RONTO, 10, -27),
new TestCase(MeasureUnit.MeasurePrefix.YOCTO, 10, -24),
new TestCase(MeasureUnit.MeasurePrefix.ZEPTO, 10, -21),
new TestCase(MeasureUnit.MeasurePrefix.ATTO, 10, -18),
Expand All @@ -4644,6 +4646,8 @@ class TestCase {
new TestCase(MeasureUnit.MeasurePrefix.EXA, 10, 18),
new TestCase(MeasureUnit.MeasurePrefix.ZETTA, 10, 21),
new TestCase(MeasureUnit.MeasurePrefix.YOTTA, 10, 24),
new TestCase(MeasureUnit.MeasurePrefix.RONNA, 10, 27),
new TestCase(MeasureUnit.MeasurePrefix.QUETTA, 10, 30),
new TestCase(MeasureUnit.MeasurePrefix.KIBI, 1024, 1),
new TestCase(MeasureUnit.MeasurePrefix.MEBI, 1024, 2),
new TestCase(MeasureUnit.MeasurePrefix.GIBI, 1024, 3),
Expand Down
28 changes: 28 additions & 0 deletions icu4j/main/core/src/main/java/com/ibm/icu/util/MeasureUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ public enum Complexity {
*/
public enum MeasurePrefix {

/**
* SI prefix: quetta, 10^30.
*
* @draft ICU 75
*/
QUETTA(30, "quetta", 10),

/**
* SI prefix: ronna, 10^27.
*
* @draft ICU 75
*/
RONNA(27, "ronna", 10),

/**
* SI prefix: yotta, 10^24.
*
Expand Down Expand Up @@ -265,6 +279,20 @@ public enum MeasurePrefix {
*/
YOCTO(-24, "yocto", 10),

/**
* SI prefix: ronto, 10^-27.
*
* @draft ICU 75
*/
RONTO(-27, "ronto", 10),

/**
* SI prefix: quecto, 10^-30.
*
* @draft ICU 75
*/
QUECTO(-30, "quecto", 10),

/**
* IEC binary prefix: kibi, 1024^1.
*
Expand Down

0 comments on commit 1bb711a

Please sign in to comment.