Why won’t this work? I’m treating values_of_bins vector as if it was a image.
rep_test_script:
eval "
ref_bin='1111'-_'0';
values_of_bins=expr('sum([x,y,z,c]<<[3,2,1,0])',2,2,2,2);
print(i(values_of_bins,ref_bin));
"
Should print 15 because 1111 from bin2dec is 15.
The purpose: This is used to develop a double dabble approach to converting really large binary and print the decimal value and vice versa.
I will use this instead:
#@cli rep_bin2dec_dd:
#@cli : Convert binary numbers to digit representation using the double dabble method. Large binary number is supported here.
rep_bin2dec_dd:
$=arg
2,2,2,2,sum([x,y,z,c]<<[3,2,1,0]) => bin_box
repeat $# {
p:=$>+1
('${arg$p}')
if im<_'0'||iM>_'1' error inv_char_det fi
-. {'0'}
eval "
const num_of_bins_set=(w#-1>>2)+((w#-1&3)?1);
bin_sets=vector(#num_of_bins_set);
index=w#-1-4;
for(ins_pos=num_of_bins_set-1,ins_pos>-1,--ins_pos,
bin_sets[ins_pos]=i(#$bin_box,crop(#-1,index,0,0,0,4,1,1,1));
index-=4;
);
bin_sets;"
echo ${} rm.
}
rm.