This article describes a shell script that handles the conversion of decimal numbers to 16-way. The existing two data files I0.txt and Q0.txt are as follows:
I0.txt Q0.txt
935 3297
385 6964
-280 12697
1768 8404
7377-852
#!bin/bash
#因为有负数, so convert to 16-bit hexadecimal number first%16x
Cat I.txt | \
awk ' {printf '%16x \ n ',} ' > I00.txt
Cat Q.txt | \
awk ' {printf '%16x \ n ',} ' > Q00.txt
#我需要的是i0 the 4-bit hexadecimal number corresponding to the. txt and q0.txt decimal numbers, with a valid 4-bit
Cut-c 13-16 i00.txt > I_mem.txt
Cut-c 13-16 q00.txt > Q_mem.txt
#不足4位的, front 0.
Cat I_mem.txt | \
awk ' {printf '%04s \ n ',} ' > I_mem_00.txt
Cat Q_mem.txt | \
awk ' {printf '%04s \ n ',} ' > Q_mem_00.txt
#将两个文件 (each 4-bit) consists of 8-bit hexadecimal numbers
Paste-d ":" I_mem_00.txt q_mem_00.txt > Rfiu_mem_00.txt
Sed ' s/://g ' rfiu_mem_00.txt > Rfiu_mem.txt
#中间数据如下:
I00.txt Q00.txt
3a7 Ce1
181 1b34
FFFFFFFFFFFFA1F 3199
6e8 20d4
1CDC FFFFFFFFFFFFFCAC
I_mem.txt Q_mem.txt
3a7 Ce1
181 1b34
FA1F 3199
6e8 20d4
1CDC FCAC
I_mem_00.txt Q_mem_00.txt
03a7 0ce1
0181 1b34
FA1F 3199
06e8 20d4
1CDC FCAC
Rfiu_mem.txt
03a70ce1
01811b34
FA1F 3199
06e820d4
1cdcfcac
Note: Perhaps this method is not the most concise, if there is a better way to ask the Master twos, greatly appreciated.