view raw
Arif YILMAZ Arif YILMAZ - 6 months ago 53
Android Question

convert string to float in android

I am trying to convert string to float but I couldnt succeed.

here is my code

float f1 = Float.parseFloat("1,9698");

the error it gives is

Invalid float "1,9698";

why is it doing this? it is a valid float


You are using a comma when you should be using a period

float f1 = Float.parseFloat("1.9698");

That should work.