0

how can i test if a float (or double) value is an integer like 1.0 or 2.00.. ? in java

there is some methode to test if the float value is an integer ?? and how can i convert it ??

24th Nov 2017, 11:34 AM
Elghozi Nasreddine
Elghozi Nasreddine - avatar
4 Respuestas
+ 1
@ghozzi you mean like this https://code.sololearn.com/ccwczhMQN2WO/?ref=app i use double instead, try to change the "a" value
25th Nov 2017, 12:33 AM
Andika Romansyah
+ 2
thank's
25th Nov 2017, 9:14 AM
Elghozi Nasreddine
Elghozi Nasreddine - avatar
0
when declare a variable, the type of data wont change unless you convert it and save in different variable example: float a = 1.00; int b; b = (int) a; or you can use -> Math.round() to round it to nearest int
24th Nov 2017, 11:56 AM
Andika Romansyah
0
@andika no just i want to convert a float value to int if the value like 1.0
24th Nov 2017, 12:25 PM
Elghozi Nasreddine
Elghozi Nasreddine - avatar