2 added 6 characters in body
source | link

Brace expansion in form {x..y} give you all possible characters from range x to y. In this case, {0..1} give you 0 and 1. Combine two pieces give you 2^2 four possible valuevalues:

$ printf %s\\n {0..1}{0..1}
00
01
10
11

Combine five passpieces give you 2^5 thirty two possible valuevalues from 0 to 32 in binary form:

$ printf %s\\n {0..1}{0..1}{0..1}{0..1}{0..1}
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
.....
11110
11111

Saving all values in D2B array, with decimal index corresponding to it binary value. Accessing index 12 ${D2B[$val]} gave you the binary value of 12 decimal.

Actually, you can make it shorter with {x,y}:

D2B=({0,1}{0,1}{0,1}{0,1}{0,1})

Brace expansion in form {x..y} give you all possible characters from range x to y. In this case, {0..1} give you 0 and 1. Combine two pieces give you 2^2 four possible value:

$ printf %s\\n {0..1}{0..1}
00
01
10
11

Combine five pass give you thirty two possible value from 0 to 32:

$ printf %s\\n {0..1}{0..1}{0..1}{0..1}{0..1}
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
.....
11110
11111

Saving all values in D2B array, with decimal index corresponding to it binary value. Accessing index 12 ${D2B[$val]} gave you the binary value of 12 decimal.

Actually, you can make it shorter with {x,y}:

D2B=({0,1}{0,1}{0,1}{0,1}{0,1})

Brace expansion in form {x..y} give you all possible characters from range x to y. In this case, {0..1} give you 0 and 1. Combine two pieces give you 2^2 four possible values:

$ printf %s\\n {0..1}{0..1}
00
01
10
11

Combine five pieces give you 2^5 thirty two possible values from 0 to 32 in binary form:

$ printf %s\\n {0..1}{0..1}{0..1}{0..1}{0..1}
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
.....
11110
11111

Saving all values in D2B array, with decimal index corresponding to it binary value. Accessing index 12 ${D2B[$val]} gave you the binary value of 12 decimal.

Actually, you can make it shorter with {x,y}:

D2B=({0,1}{0,1}{0,1}{0,1}{0,1})
1
source | link

Brace expansion in form {x..y} give you all possible characters from range x to y. In this case, {0..1} give you 0 and 1. Combine two pieces give you 2^2 four possible value:

$ printf %s\\n {0..1}{0..1}
00
01
10
11

Combine five pass give you thirty two possible value from 0 to 32:

$ printf %s\\n {0..1}{0..1}{0..1}{0..1}{0..1}
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
.....
11110
11111

Saving all values in D2B array, with decimal index corresponding to it binary value. Accessing index 12 ${D2B[$val]} gave you the binary value of 12 decimal.

Actually, you can make it shorter with {x,y}:

D2B=({0,1}{0,1}{0,1}{0,1}{0,1})