要生成UFI编号,我使用bitset大小为74.要执行UFI生成的第2步,我需要转换此数字:
9 444 732 987 799 592 368 290
(10000000000000000000000000000101000001000001010000011101011111100010100010)
Run Code Online (Sandbox Code Playgroud)
成:
DFSTTM62QN6DTV1
Run Code Online (Sandbox Code Playgroud)
通过将第一个表示转换为基数31并从表中获取等效的字符.
#define PAYLOAD_SIZE 74
// payload = binary of 9444732987799592368290
std::bitset<PAYLOAD_SIZE> bs_payload(payload);
/*
perform modulo 31 to obtain:
12(D), 14(F), 24(S), 25(T), 25, 19, 6, 2, 22, 20, 6, 12, 25, 27, 1
*/
Run Code Online (Sandbox Code Playgroud)
有没有办法在不使用外部BigInteger库的情况下对我的bitset执行转换?
编辑:BigInteger即使是干杯和赫斯,我终于完成了一堂课.- 阿尔夫的解决方案就像一个魅力
var eatsPlants = true;
var eatsAnimals = false;
var category = eatsPlants ? (eatsAnimals ? "omnivore" : "herbivore") : (eatsAnimals ? "carnivore" : "undefined");
console.log(category);Run Code Online (Sandbox Code Playgroud)
//我不明白它是如何检查多个事物的代码