Katalon Studio v5.8 - It's time for the all-new API testing experience
Marcelo Moya
Katalon Apprentice
06/13/2018

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!
Upvote
Quote

Comments

  • Marek Melocik
    Katalon Expert
    06/13/2018
    edited June 13
    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)


    Upvote
    Quote
Sign In or Register to comment.