cast::bytes_to_num now uses template