0
Check if a number is whole number or decimal number
how to check if the entered number by user is decimal or whole number?
6 ответов
+ 2
if number%1==0 it is whole
+ 3
% operator is for integers only. It's double counterpart is fmod.
Another way is to compare the number with it's floor:
if (floor(x) == x)
// x is whole
Both floor and fmod are included in <cmath>
+ 1
thanks
+ 1
if(number%1==0)
+ 1
thanks
0
(int)n==n