1 /*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "measure_data.h"
16 #include <string>
17 #include <unordered_map>
18 #include <cmath>
19 #include "utils.h"
20
21 namespace OHOS {
22 namespace Global {
23 namespace I18n {
24 using namespace std;
25 const double FT_TO_M = 0.3048;
26 const double FT2_TO_M2 = FT_TO_M * FT_TO_M;
27 const double FT3_TO_M3 = FT_TO_M * FT2_TO_M2;
28 const double IN3_TO_M3 = FT3_TO_M3 / (12 * 12 * 12);
29 const double GAL_IMP_TO_M3 = 0.00454609;
30 const double GAL_TO_M3 = 231 * IN3_TO_M3;
31 const int REGION_OFFSET = 7;
32 const int BASE_VALUE_SIZE = 2;
33 const int FACTOR_SIZE = 2;
34 const int CHAR_OFFSET = 48;
35 const int MAX_UNIT_NUM = 500;
36
37 const std::unordered_map<std::string, std::vector<std::string>> USAGE_001 {
38 { "area-land-agricult", { "hectare" } },
39 { "area-land-commercl", { "hectare" } },
40 { "area-land-residntl", { "hectare" } },
41 { "length-person", { "centimeter" } },
42 { "length-person-small", { "centimeter" } },
43 { "length-rainfall", { "millimeter" } },
44 { "length-road", { "meter" } },
45 { "length-road-small", { "meter" } },
46 { "length-snowfall", { "centimeter" } },
47 { "length-vehicle", { "meter" } },
48 { "length-visiblty", { "meter" } },
49 { "length-visiblty-small", { "meter" } },
50 { "speed-road-travel", { "kilometer-per-hour" } },
51 { "speed-wind", { "kilometer-per-hour" } },
52 { "temperature-person", { "celsius" } },
53 { "temperature-weather", { "celsius" } },
54 { "volume-vehicle-fuel", { "liter" } },
55 };
56
57 const std::unordered_map<std::string, std::vector<std::string>> USAGE_DEFAULT_001 {
58 { "length", { "kilometer", "meter", "centimeter" } },
59 { "area", { "square-kilometer", "hectare", "square-meter", "square-centimeter" } },
60 { "speed", { "kilometer-per-hour" } },
61 { "temperature", { "celsius" } },
62 { "volume", { "cubic-meter", "cubic-centimeter" } },
63 };
64
65 const std::unordered_map<std::string, std::vector<std::string>> USAGE_AT {
66 { "length-person", { "meter", "centimeter" } },
67 };
68
69 const std::unordered_map<std::string, std::vector<std::string>> USAGE_BR {
70 { "length-person-informal", { "meter", "centimeter" } },
71 { "length-rainfall", { "centimeter" } },
72 };
73
74 const std::unordered_map<std::string, std::vector<std::string>> USAGE_BS {
75 { "temperature-weather", { "fahrenheit" } },
76 };
77
78 const std::unordered_map<std::string, std::vector<std::string>> USAGE_CA {
79 { "length-person", { "inch" } },
80 { "length-person-informal", { "foot", "inch" } },
81 { "length-person-small-informal", { "inch" } },
82 };
83
84 const std::unordered_map<std::string, std::vector<std::string>> USAGE_CN {
85 { "length-person-informal", { "meter", "centimeter" } },
86 };
87
88 const std::unordered_map<std::string, std::vector<std::string>> USAGE_DE {
89 { "length-person-informal", { "meter", "centimeter" } },
90 { "length-visiblty", { "meter" } },
91 };
92
93 const std::unordered_map<std::string, std::vector<std::string>> USAGE_GB {
94 { "area-land-agricult", { "acre" } },
95 { "area-land-commercl", { "acre" } },
96 { "area-land-residntl", { "acre" } },
97 { "length-person", { "inch" } },
98 { "length-person-informal", { "foot", "inch" } },
99 { "length-person-small-informal", { "inch" } },
100 { "length-road", { "yard" } },
101 { "length-road-small", { "yard" } },
102 { "length-vehicle", { "foot", "inch" } },
103 { "length-visiblty", { "mile", "foot" } },
104 { "length-visiblty-small", { "foot" } },
105 { "speed-road-travel", { "mile-per-hour" } },
106 };
107
108 const std::unordered_map<std::string, std::vector<std::string>> USAGE_DEFAULT_GB {
109 { "length", { "mile", "foot", "inch" } },
110 { "area", { "square-mile", "acre", "square-foot", "square-inch" } },
111 { "speed", { "mile-per-hour" } },
112 { "volume", { "cubic-foot", "cubic-inch" } },
113 };
114
115 const std::unordered_map<std::string, std::vector<std::string>> USAGE_KR {
116 { "speed-wind", { "meter-per-second" } },
117 };
118
119 const std::unordered_map<std::string, std::vector<std::string>> USAGE_MX {
120 { "length-person-informal", { "meter", "centimeter" } },
121 { "length-vehicle", { "meter", "centimeter" } },
122 };
123
124 const std::unordered_map<std::string, std::vector<std::string>> USAGE_NL {
125 { "length-person-informal", { "meter", "centimeter" } },
126 { "length-visiblty", { "meter" } },
127 };
128
129 const std::unordered_map<std::string, std::vector<std::string>> USAGE_NO {
130 { "length-person-informal", { "meter", "centimeter" } },
131 { "speed-wind", { "meter-per-second" } },
132 };
133
134 const std::unordered_map<std::string, std::vector<std::string>> USAGE_SE {
135 { "length-person", { "meter", "centimeter" } },
136 { "length-road", { "mile-scandinavian", "kilometer" } },
137 { "length-road-informal", { "mile-scandinavian" } },
138 { "speed-wind", { "meter-per-second" } },
139 };
140
141 const std::unordered_map<std::string, std::vector<std::string>> USAGE_US {
142 { "area-land-agricult", { "acre" } },
143 { "area-land-commercl", { "acre" } },
144 { "area-land-residntl", { "acre" } },
145 { "length-person", { "inch" } },
146 { "length-person-informal", { "foot", "inch" } },
147 { "length-person-small", { "inch" } },
148 { "length-rainfall", { "inch" } },
149 { "length-road", { "mile" } },
150 { "length-road-small", { "foot" } },
151 { "length-snowfall", { "inch" } },
152 { "length-vehicle", { "foot", "inch" } },
153 { "length-visiblty", { "mile", "foot" } },
154 { "length-visiblty-small", { "foot" } },
155 { "speed-road-travel", { "mile-per-hour" } },
156 { "speed-wind", { "mile-per-hour" } },
157 { "temperature-person", { "fahrenheit" } },
158 { "temperature-weather", { "fahrenheit" } },
159 { "volume-vehicle-fuel", { "gallon" } },
160 };
161
162 const std::unordered_map<std::string, std::vector<std::string>> USAGE_DEFAULT_US {
163 { "length", { "mile", "foot", "inch" } },
164 { "area", { "square-mile", "acre", "square-foot", "square-inch" } },
165 { "speed", { "mile-per-hour" } },
166 { "temperature", { "fahrenheit" } },
167 { "volume", { "cubic-foot", "cubic-inch" } },
168 };
169
170 const std::unordered_map<std::string, std::vector<double>> CONVERT_FACTORS {
171 { "acre", { FT2_TO_M2 * 43560, 0 } },
172 { "hectare", { 10000, 0 } },
173 { "dunam", { 1000, 0 } },
174 { "fathom", { FT_TO_M * 6, 0 } },
175 { "foot", { FT_TO_M, 0 } },
176 { "furlong", { FT_TO_M * 660, 0 } },
177 { "inch", { FT_TO_M / 12, 0 } },
178 { "meter", { 1, 0 } },
179 { "mile", { FT_TO_M * 5280, 0 } },
180 { "mile-scandinavian", { 10000, 0 } },
181 { "nautical-mile", { 1852, 0 } },
182 { "point", { FT_TO_M / 864, 0 } },
183 { "yard", { FT_TO_M * 3, 0 } },
184 { "knot", { 1852 / 3600.0, 0 } },
185 { "kilometer-per-hour", { 1000 / 3600.0, 0 } },
186 { "celsius", { 1, 273.15 }},
187 { "fahrenheit", {5.0 / 9, 2298.35 / 9 }},
188 { "kelvin", { 1, 0 } },
189 { "acre-foot", { 43560 * FT3_TO_M3, 0 } },
190 { "bushel", { GAL_IMP_TO_M3 * 8, 0 } },
191 { "bushel-UK", { GAL_IMP_TO_M3 * 8, 0 } },
192 { "bushel-US", { IN3_TO_M3 * 2150.42, 0 } },
193 { "cup", { GAL_IMP_TO_M3 / 16, 0 } },
194 { "cup-UK", { GAL_IMP_TO_M3 / 16, 0 } },
195 { "cup-US", { GAL_TO_M3 / 16, 0 } },
196 { "cup-metric", {0.00025, 0 } },
197 { "fluid-ounce", { GAL_IMP_TO_M3 / 128, 0 } },
198 { "fluid-ounce-imperial", { GAL_IMP_TO_M3 / 160, 0 } },
199 { "gallon", { GAL_TO_M3, 0 } },
200 { "gallon-imperial", { GAL_IMP_TO_M3, 0 } },
201 { "liter", {0.001, 0 } },
202 { "pint-metric", { 0.0005, 0 } },
203 { "pint", { GAL_IMP_TO_M3 / 8, 0 } },
204 { "pint-UK", { GAL_IMP_TO_M3 / 8, 0 } },
205 { "pint-US", { GAL_TO_M3 / 8, 0 } },
206 { "quart", { GAL_IMP_TO_M3 / 4, 0 } },
207 { "quart-UK", { GAL_IMP_TO_M3 / 4, 0 } },
208 { "quart-US", { GAL_TO_M3 / 4, 0 } },
209 { "tablespoon", { GAL_IMP_TO_M3 / 256, 0 } },
210 { "tablespoon-UK", { GAL_IMP_TO_M3 / 256, 0 } },
211 { "tablespoon-US", { GAL_TO_M3 / 256, 0 } },
212 { "teaspoon", { GAL_IMP_TO_M3 / (16 * 48), 0 } },
213 { "teaspoon-UK", { GAL_IMP_TO_M3 / (16 * 48), 0 } },
214 { "teaspoon-US", { GAL_TO_M3 / (16 * 48), 0 } },
215 { "barrel", { GAL_IMP_TO_M3 * 36, 0 } },
216 { "barrel-UK", { GAL_IMP_TO_M3 * 36, 0 } },
217 { "barrel-US", { GAL_TO_M3 * 42, 0 } },
218 { "hour", { 3600, 0 } },
219 { "second", { 1, 0 } },
220 };
221
222 const std::unordered_map<std::string, std::string> CONVERT_TO_UNIT {
223 { "acre", "square-meter" },
224 { "hectare", "square-meter" },
225 { "dunam", "square-meter" },
226 { "fathom", "meter" },
227 { "foot", "meter" },
228 { "furlong", "meter" },
229 { "inch", "meter" },
230 { "meter", "meter" },
231 { "mile", "meter" },
232 { "mile-scandinavian", "meter" },
233 { "nautical-mile", "meter" },
234 { "point", "meter" },
235 { "yard", "meter" },
236 { "knot", "meter-per-second" },
237 { "kilometer-per-hour", "meter-per-second" },
238 { "celsius", "kelvin" },
239 { "fahrenheit", "kelvin" },
240 { "kelvin", "kelvin" },
241 { "acre-foot", "cubic-meter" },
242 { "bushel", "cubic-meter" },
243 { "bushel-UK", "cubic-meter" },
244 { "bushel-US", "cubic-meter" },
245 { "cup", "cubic-meter" },
246 { "cup-UK", "cubic-meter" },
247 { "cup-US", "cubic-meter" },
248 { "cup-metric", "cubic-meter" },
249 { "fluid-ounce", "cubic-meter" },
250 { "fluid-ounce-imperial", "cubic-meter" },
251 { "gallon", "cubic-meter" },
252 { "gallon-imperial", "cubic-meter" },
253 { "liter", "cubic-meter" },
254 { "pint-metric", "cubic-meter" },
255 { "pint", "cubic-meter" },
256 { "pint-UK", "cubic-meter" },
257 { "pint-US", "cubic-meter" },
258 { "quart", "cubic-meter" },
259 { "quart-UK", "cubic-meter" },
260 { "quart-US", "cubic-meter" },
261 { "tablespoon", "cubic-meter" },
262 { "tablespoon-UK", "cubic-meter" },
263 { "tablespoon-US", "cubic-meter" },
264 { "teaspoon", "cubic-meter" },
265 { "teaspoon-UK", "cubic-meter" },
266 { "teaspoon-US", "cubic-meter" },
267 { "barrel", "cubic-meter" },
268 { "barrel-US", "cubic-meter" },
269 { "barrel-UK", "cubic-meter" },
270 { "hour", "second" },
271 { "second", "second" },
272 };
273
274 const std::unordered_map<std::string, double> PREFIX_VALUE {
275 { "deci", pow(10, -1) },
276 { "centi", pow(10, -2) },
277 { "milli", pow(10, -3) },
278 { "micro", pow(10, -6) },
279 { "nano", pow(10, -9) },
280 { "pico", pow(10, -12) },
281 { "kilo", pow(10, 3) },
282 { "hecto", pow(10, 2) },
283 { "mega", pow(10, 6) },
284 };
285
286 const std::unordered_map<std::string, double> POWER_VALUE {
287 { "square-", 2 },
288 { "cubic-", 3 },
289 };
290
GetMask(const string & region)291 uint32_t GetMask(const string ®ion)
292 {
293 uint32_t firstChar = (region.c_str()[0] - CHAR_OFFSET);
294 uint32_t secondChar = (region.c_str()[1] - CHAR_OFFSET);
295 return (firstChar << REGION_OFFSET) | secondChar;
296 }
297
GetDefaultPreferredUnit(const string & region,const string & type,vector<string> & units)298 void GetDefaultPreferredUnit(const string ®ion, const string &type, vector<string> &units)
299 {
300 switch (GetMask(region)) {
301 case 0x00000B92: {
302 if (USAGE_DEFAULT_GB.count(type) > 0) {
303 units.assign(USAGE_DEFAULT_GB.at(type).begin(), USAGE_DEFAULT_GB.at(type).end());
304 }
305 break;
306 }
307 case 0x000012A3: {
308 if (USAGE_DEFAULT_US.count(type) > 0) {
309 units.assign(USAGE_DEFAULT_US.at(type).begin(), USAGE_DEFAULT_US.at(type).end());
310 }
311 break;
312 }
313 default: {
314 if (USAGE_DEFAULT_001.count(type) > 0) {
315 units.assign(USAGE_DEFAULT_001.at(type).begin(), USAGE_DEFAULT_001.at(type).end());
316 }
317 break;
318 }
319 }
320 }
321
GetFallbackPreferredUnit(const string & region,const string & usage,vector<string> & units)322 void GetFallbackPreferredUnit(const string ®ion, const string &usage, vector<string> &units)
323 {
324 switch (GetMask(region)) {
325 case 0x00000EA8: {
326 if (USAGE_MX.count(usage) > 0) {
327 units.assign(USAGE_MX.at(usage).begin(), USAGE_MX.at(usage).end());
328 return;
329 }
330 break;
331 }
332 case 0x00000F1C: {
333 if (USAGE_NL.count(usage) > 0) {
334 units.assign(USAGE_NL.at(usage).begin(), USAGE_NL.at(usage).end());
335 return;
336 }
337 break;
338 }
339 case 0x00000F1F:
340 case 0x0000101C:
341 case 0x00001125: {
342 if (USAGE_NO.count(usage) > 0) {
343 units.assign(USAGE_NO.at(usage).begin(), USAGE_NO.at(usage).end());
344 return;
345 }
346 break;
347 }
348 case 0x00001195: {
349 if (USAGE_SE.count(usage) > 0) {
350 units.assign(USAGE_SE.at(usage).begin(), USAGE_SE.at(usage).end());
351 return;
352 }
353 break;
354 }
355 case 0x000012A3: {
356 if (USAGE_US.count(usage) > 0) {
357 units.assign(USAGE_US.at(usage).begin(), USAGE_US.at(usage).end());
358 return;
359 }
360 break;
361 }
362 default: {
363 if (USAGE_001.count(usage) > 0) {
364 units.assign(USAGE_001.at(usage).begin(), USAGE_001.at(usage).end());
365 return;
366 }
367 break;
368 }
369 }
370 }
371
GetRestPreferredUnit(const string & region,const string & usage,vector<string> & units)372 void GetRestPreferredUnit(const string ®ion, const string &usage, vector<string> &units)
373 {
374 switch (GetMask(region)) {
375 case 0x00000991:
376 case 0x00000C9E: {
377 if (USAGE_CA.count(usage) > 0) {
378 units.assign(USAGE_CA.at(usage).begin(), USAGE_CA.at(usage).end());
379 return;
380 }
381 break;
382 }
383 case 0x0000099E:
384 case 0x00000A1B:
385 case 0x00001024: {
386 if (USAGE_CN.count(usage) > 0) {
387 units.assign(USAGE_CN.at(usage).begin(), USAGE_CN.at(usage).end());
388 return;
389 }
390 break;
391 }
392 case 0x00000A15: {
393 if (USAGE_DE.count(usage) > 0) {
394 units.assign(USAGE_DE.at(usage).begin(), USAGE_DE.at(usage).end());
395 return;
396 }
397 break;
398 }
399 case 0x00000B92: {
400 if (USAGE_GB.count(usage) > 0) {
401 units.assign(USAGE_GB.at(usage).begin(), USAGE_GB.at(usage).end());
402 return;
403 }
404 break;
405 }
406 case 0x00000DA2: {
407 if (USAGE_KR.count(usage) > 0) {
408 units.assign(USAGE_KR.at(usage).begin(), USAGE_KR.at(usage).end());
409 return;
410 }
411 break;
412 }
413 default: {
414 GetFallbackPreferredUnit(region, usage, units);
415 break;
416 }
417 }
418 if (!units.size()) {
419 GetFallbackPreferredUnit(region, usage, units);
420 }
421 }
422
GetPreferredUnit(const string & region,const string & usage,vector<string> & units)423 void GetPreferredUnit(const string ®ion, const string &usage, vector<string> &units)
424 {
425 switch (GetMask(region)) {
426 case 0x000008A4:
427 case 0x00000915:
428 case 0x00000A2A:
429 case 0x00000A97:
430 case 0x00000AA3:
431 case 0x00000B22:
432 case 0x00000C1B:
433 case 0x00000C94:
434 case 0x00000C9C:
435 case 0x00000CA4:
436 case 0x00000D1F:
437 case 0x00000EA9:
438 case 0x00001191:
439 case 0x00001222:
440 case 0x0000131E: {
441 if (USAGE_AT.count(usage) > 0) {
442 units.assign(USAGE_AT.at(usage).begin(), USAGE_AT.at(usage).end());
443 return;
444 }
445 break;
446 }
447 case 0x00000922: {
448 if (USAGE_BR.count(usage) > 0) {
449 units.assign(USAGE_BR.at(usage).begin(), USAGE_BR.at(usage).end());
450 return;
451 }
452 break;
453 }
454 case 0x00000923:
455 case 0x0000092A:
456 case 0x00001022:
457 case 0x00001027: {
458 if (USAGE_BS.count(usage) > 0) {
459 units.assign(USAGE_BS.at(usage).begin(), USAGE_BS.at(usage).end());
460 return;
461 }
462 break;
463 }
464 default: {
465 GetRestPreferredUnit(region, usage, units);
466 break;
467 }
468 }
469 if (!units.size()) {
470 GetRestPreferredUnit(region, usage, units);
471 }
472 }
473
ComputeFactorValue(const string & unit,const string & measSys,vector<double> & factors)474 void ComputeFactorValue(const string &unit, const string &measSys, vector<double> &factors)
475 {
476 string unitKey = unit + "-" + measSys;
477 if (CONVERT_FACTORS.count(unitKey) > 0) {
478 factors[0] = CONVERT_FACTORS.at(unitKey)[0];
479 factors[1] = CONVERT_FACTORS.at(unitKey)[1];
480 return;
481 }
482 if (CONVERT_FACTORS.count(unit) > 0) {
483 factors[0] = CONVERT_FACTORS.at(unit)[0];
484 factors[1] = CONVERT_FACTORS.at(unit)[1];
485 }
486 }
487
ComputeSIPrefixValue(const string & unit)488 double ComputeSIPrefixValue(const string &unit)
489 {
490 for (auto& prefixValue : PREFIX_VALUE) {
491 if (!unit.rfind(prefixValue.first, 0)) {
492 return prefixValue.second;
493 }
494 }
495 return 0.0;
496 }
497
ComputePowerValue(const string & unit,const string & measSys,vector<double> & factors)498 void ComputePowerValue(const string &unit, const string &measSys, vector<double> &factors)
499 {
500 for (auto& powerValue : POWER_VALUE) {
501 if (!unit.rfind(powerValue.first, 0)) {
502 string baseUnit = unit.substr(powerValue.first.length());
503 double value = ComputeSIPrefixValue(baseUnit);
504 double compare = 0.0;
505 if (fabs(value - compare) < 1e-6) {
506 ComputeFactorValue(baseUnit, measSys, factors);
507 }
508 factors[0] = pow(factors[0], powerValue.second);
509 }
510 }
511 }
512
ComputeValue(const string & unit,const string & measSys,vector<double> & factors)513 int ComputeValue(const string &unit, const string &measSys, vector<double> &factors)
514 {
515 if (unit.find("-per-") != string::npos) {
516 vector<string> baseValues;
517 Split(unit, "-per-", baseValues);
518 if (baseValues.size() == BASE_VALUE_SIZE) {
519 vector<double> numerator = { 1.0, 0.0 };
520 int status = ComputeValue(baseValues[0], measSys, numerator);
521 if (!status) {
522 return 0;
523 }
524 vector<double> denominator = { 1.0, 0.0 };
525 status = ComputeValue(baseValues[1], measSys, denominator);
526 if (!status) {
527 return 0;
528 }
529 factors[0] = numerator[0] / denominator[0];
530 return 1;
531 }
532 }
533 double compare = 0.0;
534 factors[0] = ComputeSIPrefixValue(unit);
535 if (fabs(factors[0] - compare) < 1e-6) {
536 ComputePowerValue(unit, measSys, factors);
537 }
538 if (fabs(factors[0] - compare) < 1e-6) {
539 ComputeFactorValue(unit, measSys, factors);
540 }
541 if (fabs(factors[0] - compare) < 1e-6) {
542 factors[0] = 1.0;
543 return 0;
544 }
545 return 1;
546 }
547
Convert(double & value,const string & fromUnit,const string & fromMeasSys,const string & toUnit,const string & toMeasSys)548 int Convert(double &value, const string &fromUnit, const string &fromMeasSys, const string &toUnit,
549 const string &toMeasSys)
550 {
551 double baseResult = 0.0;
552 double result = 0.0;
553 vector<double> fromFactors = {0.0, 0.0};
554 string fromUnitType;
555 string toUnitType;
556 icu::MeasureUnit unitArray[MAX_UNIT_NUM];
557 UErrorCode icuStatus = U_ZERO_ERROR;
558 icu::MeasureUnit::getAvailable(unitArray, MAX_UNIT_NUM, icuStatus);
559 if (!U_SUCCESS(icuStatus)) {
560 return 0;
561 }
562 for (icu::MeasureUnit curUnit : unitArray) {
563 if (!strcmp(curUnit.getSubtype(), fromUnit.c_str())) {
564 fromUnitType = curUnit.getType();
565 }
566 if (!strcmp(curUnit.getSubtype(), toUnit.c_str())) {
567 toUnitType = curUnit.getType();
568 }
569 }
570 if (fromUnitType.empty() || toUnitType.empty() || strcmp(fromUnitType.c_str(), toUnitType.c_str())) {
571 return 0;
572 }
573 int status = ComputeValue(fromUnit, fromMeasSys, fromFactors);
574 if (!status) {
575 return 0;
576 }
577 vector<double> toFactors = {0.0, 0.0};
578 status = ComputeValue(toUnit, toMeasSys, toFactors);
579 if (!status) {
580 return 0;
581 }
582 if (fromFactors.size() == FACTOR_SIZE) {
583 baseResult = fromFactors[0] * value + fromFactors[1];
584 }
585 if (toFactors.size() == FACTOR_SIZE) {
586 result = (baseResult - toFactors[1]) / toFactors[0];
587 }
588 value = result;
589 return 1;
590 }
591 } // namespace I18n
592 } // namespace Global
593 } // namespace OHOS