简体   繁体   English

Scodec-长度指定为输入的文字二进制无符号整数字符串吗?

[英]Scodec - Literal binary unsigned integer string with length specified as input?

raw beginner with scodec here. scodec的原始初学者。 Does scodec provide a nice way to convert an unsigned decimal integer value to a literal binary unsigned integer string with length specified as an input, left-padding with zeroes as needed up to the specified length? scodec是否提供一种将无符号的十进制整数值转换为文字长度为二进制的无符号整数字符串的好方法,该字符串的长度指定为输入,并根据需要用零填充到指定的长度,以左填充? If so, what would that be? 如果是这样,那会是什么? Many thanks... 非常感谢...

Sample pseudocode: 样本伪代码:
{convert(unsignedDecimalIntValue = 5, bitCount = 6) => "000101"} {convert(unsignedDecimalIntValue = 5,bitCount = 6)=>“ 000101”}

Colt Frederickson kindly answered this on Gitter for the particular case in my example above: Colt Frederickson在上面的示例中针对特殊情况在Gitter上对此表示感谢:

BitVector.fromInt(5).takeRight(6).toBin 

Generalizing the Int arguments to the terms of my pseudocode, 将Int参数推广到我的伪代码的条款中,

BitVector.fromInt(unsignedDecimalIntValue).takeRight(bitCount).toBin 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM