I need to print values that are in a matrix, these may vary from integer to real. As an example a matrix that my program use, named kernel, is shown below:
kernel[0,0]:= 1/16;
kernel[0,1]:= 2/16;
kernel[0,2]:= 1/16;
kernel[1,0]:= 2/16;
kernel[1,1]:= 4/16;
kernel[1,2]:= 2/16;
kernel[2,0]:= 1/16;
kernel[2,1]:= 2/16;
kernel[2,2]:= 1/16;
the issue comes when printing each of them, because I couldn't find a way to print a number like 1/16
in a easy-to-read way, the program displays something like 6.2500000000000000000000000000E-2
which is OK but I would prefer to have something more aesthetic like 0.0625
or even better 1/16
. Does anyone acknowledge a way of formatting that allows me to do so?