conversion {cnum} | R Documentation |
Chinese Numerals Conversion
Description
Functions to convert between Chinese and Arabic numerals.
Usage
c2num(
x,
lang = default_cnum_lang(),
mode = "casual",
financial = FALSE,
literal = FALSE
)
num2c(
x,
lang = default_cnum_lang(),
mode = "casual",
financial = FALSE,
literal = FALSE,
single = FALSE
)
Arguments
x |
the Arabic/Chinese numerals to be converted, or a vector of them. The absolute value must not be greater than 1e+18. |
lang |
the language of the Chinese numerals. |
mode |
the scale naming system to be enforced. See the ‘Details’ section for the list of supported modes. |
financial |
logical: should the financial numerals be used (daxie shuzi)? |
literal |
logical: should the numerals be converted literally? (e.g. 721 to be converted to "qi er yi" instead of "qibai ershiyi" and vice versa) |
single |
logical: should the return result with one scale character only? (e.g. 1.5e+08 as "yi dian wuyi" instead of "yiyi wuqianwan") |
Value
c2num
returns a numeric vector.
num2c
returns a character vector.
Functions
-
c2num
: Convert Chinese Numerals to Arabic Numerals. -
num2c
: Convert Arabic Numerals to Chinese Numerals.
Details
The following scale naming systems are supported:
-
"casual"
: the casual naming system used outside of mainland China, i.e. 1e+09 is referred to as "yi zhao". -
"casualPRC"
: the casual naming system used in mainland China, i.e. 1e+9 is referred to as "yi wanyi". -
"SIprefix"
: the SI prefix system used in Taiwan as stipulated in the document Names, Definitions and Symbols of the Legal Units of Measurement and the Decimal Multiples and Submultiples. "SIprefixPRC"
: the SI prefix system used in mainland China as stipulated in the document China Statutory Measurement Units."SIprefixPRClong"
: a variant of"SIprefixPRC"
with long prefixes, e.g. 1e+09 is referred to as "yi jika" instead of "yi ji".
Warnings
The modes "casual"
and "casualPRC"
implements a “myriad scale” with an interval of 1e+04 for large numbers,
i.e. "yi" is 10,000 times of "wan", which is different from
some of the interval systems used in ancient Chinese writings.
This package supports conversion of numbers with absolute value not greater than 1e+18. Note that numbers in R are in double precision that carries approximately 16 significant digits. The conversion accuracy for numbers beyond this limit is therefore not guaranteed.
References
The standard for mode "SIprefix"
Names, Definitions
and Symbols of the Legal Units of Measurement and the Decimal Multiples and
Submultiples is available from
https://gazette.nat.gov.tw/egFront/detail.do?metaid=108965 (in
Traditional Chinese).
The standard for mode "SIprefixPRC"
China Statutory
Measurement Units is available from
http://gkml.samr.gov.cn/nsjg/jls/201902/t20190225_291134.html (in
Simplified Chinese).
See Also
Functions for detetction and extraction
Examples
c2num("EXAMPLE CHECK")
num2c(721)
num2c(-6)
num2c(3.14)
num2c(721, literal = TRUE)
num2c(1.45e12, financial = TRUE)
num2c(6.85e12, lang = "sc", mode = "casualPRC")
num2c(1.5e9, mode = "SIprefix", single = TRUE)