fix: numeric mode for RS decoder (#13)

This commit is contained in:
mrhso 2023-12-24 01:13:21 +08:00 committed by GitHub
parent ece541bc19
commit e21683438b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1173,20 +1173,20 @@ function readDataBits(data_bits){
for(var i=0; i < Math.floor((length + 2) / 3); i++){
if(i == Math.floor((length + 2) / 3) - 1){
if(length % 3 == 0){
num += parseInt(data_bits.substring(0,10), 2);
num += parseInt(data_bits.substring(0,10), 2).toString().padStart(3, "0");
temp_data += data_bits.substring(0,10);
data_bits = data_bits.substring(10);
} else if(length % 3 == 1){
num += parseInt(data_bits.substring(0,4), 2);
num += parseInt(data_bits.substring(0,4), 2).toString();
temp_data += data_bits.substring(0,4);
data_bits = data_bits.substring(4);
} else {
num += parseInt(data_bits.substring(0,7), 2);
num += parseInt(data_bits.substring(0,7), 2).toString().padStart(2, "0");
temp_data += data_bits.substring(0,7);
data_bits = data_bits.substring(7);
}
} else {
num += parseInt(data_bits.substring(0,10), 2);
num += parseInt(data_bits.substring(0,10), 2).toString().padStart(3, "0");
temp_data += data_bits.substring(0,10);
data_bits = data_bits.substring(10);
}