/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <math.h>
template <typename T=int>
T getNumberLength(T number) {
return std::floor(std::log10(number)+1);
}
int main()
{
int a {1};
int b {12};
int c {123};
float f{1.0};
float g{3.14};
std::cout << "1\t: " << getNumberLength(a) << std::endl;
std::cout << "12\t: " << getNumberLength(b) << std::endl;
std::cout << "123\t: " << getNumberLength(c) << std::endl;
std::cout << "1.0\t: " << getNumberLength(f) << std::endl;
std::cout << "3.14\t: " << getNumberLength(g) << std::endl;
std::cout << "M_PI\t: " << getNumberLength(M_PI) << std::endl;
return 0;
}