For the binary representations in machines, only numbers with fractions denominated by 2's exponents can be precisely represented with finite number of digits. Among these, octal numbers are closest to the familiar decimal numbers.
The denominator is n
th power of 8. Numeration runs in decimal integer i
.
shopt -s extglob m=2 # leading octal integer part n=3 # number of fractional octal digits i=0 # the decimal numerator while ((i<10000)); do s=`printf %0${n}o $((i%8**n))`;s=`printf %0${m}o $((i/8**n))`${s%%*(0)} r=`echo "$i*8^(-$n)"|bc -l`;if [[ "${r}" =~ '.' ]];then r=${r%%*(0)};fi echo str=${s}, value=${r} i=$((i+1)) done