Check if a Float value is equivalent to an Integer value | C ++ program to implement the above approach ; Function to check if N is equivalent to an integer ; Convert float value of N to integer ; If N is not equivalent to any integer ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isInteger ( double N ) { int X = N ; double temp2 = N - X ; if ( temp2 > 0 ) { return false ; } return true ; } int main ( ) { double N = 1.5 ; if ( isInteger ( N ) ) { cout << " YES " ; } else { cout << " NO " ; } return 0 ; }