NumericConstants(base)
NumericConstants()所属R语言包:base
Numeric Constants
数字常量
译者:生物统计家园网 机器人LoveR
描述----------Description----------
How R parses numeric constants.
如何ŕ解析数字常量。
Details
详情----------Details----------
R parses numeric constants in its input in a very similar way to C99 floating-point constants.
ŕ解析在其输入在一个非常类似的方式,C99的浮点常量数字常量。
Inf and NaN are numeric constants (with typeof(.) "double"). These are recognized ignoring case, as is infinity as an alternative to Inf. NA_real_ and NA_integer_ are constants of types "double" and "integer" representing missing values. All other numeric constants start with a digit or period and are either a decimal or hexadecimal constant optionally followed by L.
Inf和NaN(typeof(.) "double")数字常量。这些都是公认的忽略大小写,如infinity替代Inf。 NA_real_和NA_integer_"double"和"integer"代表缺失值常量的类型。所有其他的数字常量以数字或期间开始是十进制或十六进制常数L选择性地遵循。
Hexadecimal constants start with 0x or 0X followed by a nonempty sequence from 0-9 a-f A-F . which is interpreted as a hexadecimal number, optionally followed by a binary exponent. A binary exponent consists of a P or p followed by an optional plus or minus sign followed by a non-empty sequence of (decimal) digits, and indicates multiplication by a power of two. Thus 0x123p456 is 291 * 2^456.
十六进制常量开始0x或0X0-9 a-f A-F .这被解释为十六进制数,可选二进制指数从非空序列之后。二进制指数由P或p随后由非空序列(十进制)数字可选的加号或减号,表示由两个功率相乘。因此0x123p456是291 * 2^456。
Decimal constants consist of a nonempty sequence of digits possibly containing a period (the decimal point), optionally followed by a decimal exponent. A decimal exponent consists of an E or e followed by an optional plus or minus sign followed by a non-empty sequence of digits, and indicates multiplication by a power of ten.
十进制常量由一个非空的数字可能含有一个句号(小数点),可选小数指数序列。十进制指数由E或e其次是由一个非空的数字序列可选加或减的迹象,表明由10的幂的乘法。
Values which are too large or too small to be representable will overflow to Inf or underflow to 0.0.
值过大或过小,表示会溢出Inf0.0或下溢。
A numeric constant immediately followed by i is regarded as an imaginary complex number.
一个数字常量立即i被视为一个虚构的复数。
An numeric constant immediately followed by L is regarded as an integer number when possible (and with a warning if it contains a ".").
一个数字常量紧接着Linteger时,可能被视为(警告,如果它包含一个".")。
Only the ASCII digits 0–9 are recognized as digits, even in languages which have other representations of digits. The "decimal separator" is always a period and never a comma.
只有ASCII数字0-9被确认为数字,即使在有其他数字表示的语言。 小数点分隔符“始终是一个时期,从来没有一个逗号。
Note that a leading plus or minus is not regarded by the parser as part of a numeric constant but as a unary operator applied to the constant.
请注意,领先的加或减不被视为一个数字常量的一部分,但作为一元运算符应用的不断解析器。
注意----------Note----------
When a string is parsed to input a numeric constant, the number may or may not be representable exactly in the C double type used. If not one of the nearest representable numbers will be returned.
当一个字符串被解析输入一个数值常量,可能或可能不完全在C双用式表示。如果没有一个最近表示数字将被退回。
R's own C code is used to convert constants to binary numbers, so the effect can be expected to be the same on all platforms implementing full IEC 600559 arithmetic (the most likely area of difference being the handling of numbers less than .Machine$double.xmin).
使用R的自己的C代码转换成二进制数的常数,所以可以预期的效果,所有执行的充分IEC 600559算术(差异最可能的区域作为处理数字少于.Machine$double.xmin平台是相同)。
参见----------See Also----------
Syntax.
Syntax。
Quotes for the parsing of character constants,
Quotes解析字符常量,
举例----------Examples----------
2.1
typeof(2)
sqrt(1i) # remember elementary math?[记得小学数学吗?]
utils::str(0xA0)
identical(1L, as.integer(1))
## You can combine the "0x" prefix with the "L" suffix :[#你可以结合起来的“L”后缀“0x”前缀:]
identical(0xFL, as.integer(15))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|