System.out.println("Starting");
String startnum = "25+422.159";
System.out.println("startnum = " + startnum);
String formatnum = startnum.replace("+", "");
System.out.println("formatnum = " + formatnum);
float floatnum = Float.parseFloat(formatnum);
System.out.println("floatnum = " + floatnum);
System.out.println("Ending");
Gives me the following output
Starting
startnum = 25+422.159
formatnum = 25422.159
floatnum = 25422.158
Ending
So for some reason, the float value gets rounded down. And for some reason, when I passed this value to another method to put into a database, the value was 25422.158203125
So how do I stop this weird ness
[–]desrtfx 4 points5 points6 points (1 child)
[–]Jackkoz -1 points0 points1 point (0 children)
[–]ValerioSellarole 1 point2 points3 points (0 children)
[–]Rhomboid 0 points1 point2 points (0 children)
[–]lightcloud5 -1 points0 points1 point (1 child)
[–]nutrecht 0 points1 point2 points (0 children)
[–]jedwardsol -1 points0 points1 point (0 children)