Check if a Float value is equivalent to an Integer value | Java 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
import java . util . * ; class GFG { static boolean isInteger ( double N ) { int X = ( int ) N ; double temp2 = N - X ; if ( temp2 > 0 ) { return false ; } return true ; } public static void main ( String [ ] args ) { double N = 1.5 ; if ( isInteger ( N ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }