intToBits()
R语言中的函数用于将整数转换为位,即0和1。输出的长度是整数向量长度的 32 倍。
用法: intToBits(x)
参数:
x:整数或整数向量
范例1:
# R program to convert an integer to bits
# Calling the intToBits() function
intToBits(0)
intToBits(1)
intToBits(2)
输出:
[1] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [26] 00 00 00 00 00 00 00 [1] 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [26] 00 00 00 00 00 00 00 [1] 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [26] 00 00 00 00 00 00 00
范例2:
# R program to convert an integer to bits
# Creating a vector
x <- c(0, 1, 2)
# Calling the intToBits() function
intToBits(x)
输出:
[1] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [26] 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [51] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 [76] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
相关用法
- R语言 as.integer()用法及代码示例
- R语言 is.integer()用法及代码示例
- R语言 strtoi()用法及代码示例
- R语言 utf8ToInt()用法及代码示例
- R语言 intToUtf8()用法及代码示例
- R语言 as.binary()用法及代码示例
- R语言 type.convert()用法及代码示例
- R语言 toupper()用法及代码示例
- R语言 charToRaw()用法及代码示例
- R语言 dQuote()用法及代码示例
- R语言 sQuote()用法及代码示例
- R语言 deg2rad()用法及代码示例
- R语言 rad2deg()用法及代码示例
- R语言 str_to_title()用法及代码示例
- R语言 as.factor()用法及代码示例
- R语言 as.ordered()用法及代码示例
- R语言 as.list()用法及代码示例
- R语言 data.matrix()用法及代码示例
- R语言 as.character()用法及代码示例
- R语言 as.logical()用法及代码示例
- R语言 as.Date()用法及代码示例
- R语言 as.vector()用法及代码示例
- R语言 as.matrix()用法及代码示例
注:本文由纯净天空筛选整理自nidhi_biet大神的英文原创作品 Convert an Integer to Bits in R Programming – intToBits() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。