+ 2
How do I test a number Is it an integer or float ? I need help
5 Réponses
+ 8
Another way or c++'s way of doing:
cout << typeid(3.14).name();
// if the output is "f" then it means float, if "i" it means integer
+ 4
For an int
x%1 = 0
But that becomes false for floats 🙂
+ 2
As I understand it, modulo operator % only works with integral type operands, it doesn't work for floating point type operands. I wouldn't count on it to "check" whether a given value is either an integral or a floating point type.
+ 1
Thanks 😊