Conditional based on variable type?

IMO, reinventing strlen() is simply making unnecessary extra work work for yourself.

Also:

void print (const float& f, int dec = 2) {

'dec' is unlikely to be negative. So, why use a signed 'int'?