0

Why does parsing a float into array cause precision loss error. I am trying to sort data from a text file that contains text, integers and float numbers. Using the for statement causes loss of precision errors. How do I correct this please.

float y;
for (float k = 0; k < array.length; k++);
float y = Float.parseFloat( array[k] );
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
0

Why would you declare "k" as type float? It should be declared as an int. Also, the ";" at the end of the for loop ends the loop. In other words, the for loop does not apply to the line directly after it since the ";" is there. Repost the code and tell us what errors (if any) you get.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.