What kind of magic happen with bytes in memory?
It depends on the operating system, as for Unix it does not have a system call which displays decimal numbers. The usual way of "displaying" anything is via the
ssize_t write(int fd, const void *buf, size_t nbytes);
fd is the file descriptor, specifying which file to write to (eg. stdout),
buf a pointer, pointing to the start address of a byte array and
nbytes tells the OS how many bytes it shall write.
buf is crucial, it is a character array, so you will have to convert the number you want to "display" to the decimal representation's characters yourself1, it is not the job of the OS itself.
1: Probably you will use an existing implementation, for example
stdio.h from the C standard library for which you can find the source code here.