in java, i have an array of floats, some of them are negative numbers, like :
3.04, 9.02, -4.2, -3.21, 0.02, -0.34
I only want to get the float numbers higher than 2, so I used :
if(number > 2.0 ) print.. etc
but what i get is not only the numbers >2, also the negative numbers :
3.04, 9.02, -4.2, -3.21
what could be the problem ?
what could be the problem ?Looks to me like you took the absolute value of the numbers before the test.Stringtofloat... are you remembering to take the sign in as you parse the string? You should show us the code that assignsnumberand the part that prints it.