Multiple points float

Hi,

I have the following code:

String s = “556.666”

float e = Float.valueOf(s)

println('Resultado: ’ + e)

It works perfect

String s = “3.556.666”

float e = Float.valueOf(s)

println('Resultado: ’ + e)

It does not work

06-13-2018 11:16:53 AM - [ERROR] - Test Cases/Calculo Gasto Comun FAILED because (of) java.lang.NumberFormatException: multiple points

Help!

Hi Marcelo,

float is decimal number in Java. Decimal numbers have only one dot separator, so this is expected error. Is this number (556.666) supposed to be five hundred fifty-six point triple-six **or **_five hundred fifty-six thousands six hundred sixty-six?
_
In second case, you have to remove dot and then parse String to int (as float is usually used for decimal numbers)

String s = "3.556.666".replace(".", "")
int e = Integer.parseInt(s)
println('Resultado: ' + e)
1 Like