binary to decimal; factorial template functions